Пример #1
0
        public ActionResult Login(UserBaseModel model)
        {
            var passwordHash = model.Password.GetHashString();

            var loginStatus = _authCommonService.Login(model.Email, passwordHash);
            //todo:получать returnUrl параметром
            var returnUrl = HttpContext.Request.UrlReferrer.AbsoluteUri.Replace("/Admin/Home/Login?returnUrl=", "");

            if (loginStatus.IsSuccess)
            {
                var webUser = new WebUser()
                {
                    Email        = loginStatus.Value.Email,
                    IsAuthorized = true,
                    UserId       = loginStatus.Value.Id,
                    FirstName    = loginStatus.Value.FirstName,
                    LastName     = loginStatus.Value.LastName
                };
                System.Web.HttpContext.Current.Session["UserSession"] = webUser;
                _wishService.ComplementWishs(webUser.UserId);
                _userService.SetUserCookie(webUser.UserId);
                return(Json(new BaseResponse <string>(0, "Успешно", returnUrl)));
            }
            return(Json(loginStatus));
        }