public ActionResult ResetPassword(ResetPasswordModel model) { if (ModelState.IsValid) { //verify the ResetCode. User user = UserRepository.VerifyResetCode(_db, model.ResetCode); //change the user's password. if (UserRepository.ResetPassword(_db, user, model.NewPassword)) { //delete the reset code so it can't be used again. UserRepository.DeleteResetCode(_db, model.ResetCode); this.FlashInfo("Password Successfully Reset"); return RedirectToAction("ResetPasswordSuccess"); } else { ModelState.AddModelError("", "Failed to reset password. Make sure the new password is valid."); this.FlashValidationSummaryErrors(); } } // If we got this far, something failed, redisplay form return View(model); }
public ActionResult ResetPassword(string Id) { //verify the ResetCode. User user = UserRepository.VerifyResetCode(_db, Id); var model = new ResetPasswordModel() { ResetCode = Id }; return View(model); }