Exemple #1
0
        protected override JsonResult Json(object data, string contentType, Encoding contentEncoding, JsonRequestBehavior behavior)
        {
            if (!(data is AjaxResponse))
            {
                data = new MvcAjaxResponse(data);
            }

            return(new AbpJsonResult
            {
                Data = data,
                ContentType = contentType,
                ContentEncoding = contentEncoding,
                JsonRequestBehavior = behavior
            });
        }
Exemple #2
0
        public virtual async Task <JsonResult> Login(LoginViewModel loginModel, string returnUrl = "", string returnUrlHash = "")
        {
            JsonResult jsonResult;

            this.CheckModelState();
            IActiveUnitOfWork current = this._unitOfWorkManager.Current;

            current.DisableFilter(new string[] { "MayHaveTenant" });
            AbpUserManager <Tenant, Role, FuelWerx.Authorization.Users.User> .AbpLoginResult loginResultAsync = await this.GetLoginResultAsync(loginModel.UsernameOrEmailAddress, loginModel.Password, loginModel.TenancyName);

            AbpUserManager <Tenant, Role, FuelWerx.Authorization.Users.User> .AbpLoginResult abpLoginResult = loginResultAsync;
            if (!abpLoginResult.User.ShouldChangePasswordOnNextLogin)
            {
                await this.SignInAsync(abpLoginResult.User, abpLoginResult.Identity, loginModel.RememberMe);

                if (string.IsNullOrWhiteSpace(returnUrl))
                {
                    returnUrl = this.Url.Action("Index", "Application");
                }
                if (!string.IsNullOrWhiteSpace(returnUrlHash))
                {
                    returnUrl = string.Concat(returnUrl, returnUrlHash);
                }
                FuelWerx.Authorization.Users.User user = await this._userManager.FindByNameOrEmailAsync(loginModel.UsernameOrEmailAddress.ToString());

                FuelWerx.Authorization.Users.User user1 = user;
                if (user1 != null)
                {
                    string userPostLoginViewType = await this._userAppService.GetUserPostLoginViewType(user1.Id);

                    if (!string.IsNullOrEmpty(userPostLoginViewType))
                    {
                        this.Session.Add("PostLoginRedirectCheck", userPostLoginViewType);
                    }
                    bool flag = await this._userAppService.ShowScreencastAtLogin(user1.Id);

                    if (flag)
                    {
                        this.Session.Add("ShowScreencastAtLoginCheck", flag);
                    }
                }
                AccountController accountController = this;
                MvcAjaxResponse   mvcAjaxResponse   = new MvcAjaxResponse()
                {
                    TargetUrl = returnUrl
                };
                jsonResult = accountController.Json(mvcAjaxResponse);
            }
            else
            {
                abpLoginResult.User.SetNewPasswordResetCode();
                AccountController      accountController1 = this;
                MvcAjaxResponse        mvcAjaxResponse1   = new MvcAjaxResponse();
                UrlHelper              url = this.Url;
                ResetPasswordViewModel resetPasswordViewModel = new ResetPasswordViewModel();
                long id = abpLoginResult.User.Id;
                resetPasswordViewModel.UserId    = SimpleStringCipher.Encrypt(id.ToString(), "gsKnGZ041HLL4IM8");
                resetPasswordViewModel.ResetCode = abpLoginResult.User.PasswordResetCode;
                mvcAjaxResponse1.TargetUrl       = url.Action("ResetPassword", resetPasswordViewModel);
                jsonResult = accountController1.Json(mvcAjaxResponse1);
            }
            return(jsonResult);
        }