public ActionResult ForgetPassword(ForgetPasswordModel model) { try { var newPassword = Membership.Provider.ResetPassword(model.Email, model.PasswordAnswer); return RedirectToAction("ChangePassword", new ChangePasswordModel() { OldPassword = newPassword }); } catch (Exception ex) { ModelState.AddModelError("", ex.Message); return View(model); } }
public ActionResult ForgetPasswordSetEmail(ForgetPasswordModel model) { if (!string.IsNullOrEmpty(model.Email)) { MembershipUser user = Membership.GetUser(model.Email, true /* userIsOnline */); if (user == null) { ModelState.AddModelError("", "Can not find user with given email."); return View(model); } FormsAuthentication.SetAuthCookie(model.Email, false /* createPersistentCookie */); model.PasswordQuestion = user.PasswordQuestion; model.PasswordAnswer = ""; return RedirectToAction("ForgetPassword", new {Email = model.Email }); } return View(model); }