public async Task<ActionResult> ResetPassword(PasswordResetViewModel request) { AuthManager.SignOut(); // compare passwords if (request.NewPassword != request.ConfirmPassword) { ModelState.AddModelError("", Resources.User.Strings.ErrorPasswordsDoNotMatch); } // if something is wrong in the model, return view if (!ModelState.IsValid) { request.NewPassword = String.Empty; request.ConfirmPassword = String.Empty; return View(request); } // Everything okay, reset password try { IdentityResult result = await userManager.ResetPasswordAsync(request.UserId, request.Token, request.NewPassword); if (result.Succeeded) { return View("PasswordReset"); } // password reset failed foreach (var error in result.Errors) { ModelState.AddModelError("", error); } } catch (InvalidOperationException e) { ModelState.AddModelError("", e.Message); } catch (Exception) { throw; } request.NewPassword = String.Empty; request.ConfirmPassword = string.Empty; return View(request); }
public ActionResult ResetPassword(String userId, String token, String returnUrl = "") { AuthManager.SignOut(); ViewBag.ReturnUrl = returnUrl; PasswordResetViewModel request = new PasswordResetViewModel { UserId = userId, Token = token }; return View(request); }