示例#1
0
        public async Task <IActionResult> ResetPassword(mdlResetPassword resetPasswordModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(resetPasswordModel));
            }

            var user = await _userManager.FindByEmailAsync(resetPasswordModel.Email);

            if (user == null)
            {
                RedirectToAction(nameof(ResetPasswordConfirmation));
            }

            var resetPassResult = await _userManager.ResetPasswordAsync(user, resetPasswordModel.Token, resetPasswordModel.Password);

            if (!resetPassResult.Succeeded)
            {
                foreach (var error in resetPassResult.Errors)
                {
                    ModelState.TryAddModelError(error.Code, error.Description);
                }

                return(View());
            }

            return(RedirectToAction(nameof(ResetPasswordConfirmation)));
        }
示例#2
0
        public IActionResult ResetPassword(string token, string email)
        {
            var model = new mdlResetPassword {
                Token = token, Email = email
            };

            return(View(model));
        }