public ActionResult ForgotPassword(VerificationModel vModel) { if (ModelState.IsValid) { BUserProfile bUserProfile=new BUserProfile(); UserProfile userProfile = bUserProfile.GetSingle(vModel.Email); if (userProfile != null) { if (!string.IsNullOrEmpty(vModel.Email)) { string token = WebSecurity.GeneratePasswordResetToken(vModel.Email, 2880); //Send Email string body = string.Empty; using (StreamReader reader = new StreamReader(Server.MapPath("~/content/template/PasswordResetTemplate.html"))) { body = reader.ReadToEnd(); } body = body.Replace("{USERNAME}",userProfile.FirstName +" "+ userProfile.LastName); body = body.Replace("{RESET_LINK}", "http://jobs.schoolgap.com/Account/PasswordReset?reset-id="+token); Notifications.Send(vModel.Email, "", "", "Password Reset Request", body, true); return RedirectToAction("ForgotPassword", "Account", new { sent = "1" }); } } } return View(); }
public ActionResult PasswordReset(PasswordResetModel password) { if (ModelState.IsValid) { if (!string.IsNullOrEmpty(password.ResetToken)) { BUserProfile bUserProfile=new BUserProfile(); UserProfile uProfile = bUserProfile.GetSingle(password.Email); if (uProfile != null) { ; if (WebSecurity.ResetPassword(password.ResetToken, password.NewPassword)) { return RedirectToAction("PasswordReset", "Account", new { sent = "1" }); } else { return RedirectToAction("PasswordReset", "Account", new { sent = "-1" }); } } } } return View(password); }