Пример #1
0
        public async Task <ActionResult> ChangePassword(ChangePasswordViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var result = await UserManager.ChangePasswordAsync(User.Identity.GetUserId(), model.OldPassword, model.NewPassword);

            if (result.Succeeded)
            {
                var user = await UserManager.FindByIdAsync(User.Identity.GetUserId());

                if (user != null)
                {
                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);
                }
                AppUserHelpers.UpdateAppUserEntityStatusIfForcedPasswordChange(AppUserHelpers.GetAppUserIdFromUser(User), User);
                return(RedirectToAction("Index", "Home"));
            }
            AddErrors(result);
            return(View(model));
        }