Exemple #1
0
        public IActionResult ResetPassword(string code = null)
        {
            if (code == null)
            {
                throw new ApplicationException("A code must be supplied for password reset.");
            }
            var model = new ResetPasswordViewModel {
                Code = code
            };

            return(View(model));
        }
Exemple #2
0
        public async Task <IActionResult> ResetPassword(ResetPasswordViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var user = await _userManager.FindByEmailAsync(model.Email);

            if (user == null)
            {
                // Don't reveal that the user does not exist
                return(RedirectToAction(nameof(ResetPasswordConfirmation)));
            }
            var result = await _userManager.ResetPasswordAsync(user, model.Code, model.Password);

            if (result.Succeeded)
            {
                return(RedirectToAction(nameof(ResetPasswordConfirmation)));
            }
            AddErrors(result);
            return(View());
        }