public ActionResult ResetPassword(ResetPasswordViewModel model) { if (ModelState.IsValid) { // Do the password match? if (model.Password != model.ConfirmPassword) { // No, so error and hit the view at the bottom of the method ModelState.AddModelError("", "Password and confirmation do not match."); } else { // Yes, they match bool passwordReset = WebSecurity.ResetPassword(model.Token, model.Password); if (passwordReset) { // Success ViewBag.PasswordReset = true; return View(); } else { // Problem with the token ModelState.AddModelError("", "The token you have provided is invalid or has expired."); } } } // Problem ViewBag.PasswordReset = false; return View(model); }
public ActionResult ResetPassword(String token) { // Send the token to the page ResetPasswordViewModel model = new ResetPasswordViewModel(); model.Token = token; ViewBag.PasswordReset = false; return View(model); }