public ActionResult ForgetPassword(string key) { BLL.ForgetPasswordRequest req = _forgetPasswordRequestService.GetValidRequest(key); if (req != null) { Models.ForgotPasswordModel model = new Models.ForgotPasswordModel(); model.UserProfilID = req.UserProfileID; return(View("ForgetPassword", model)); } return(new EmptyResult()); }
public ActionResult ForgetPassword(Models.ForgotPasswordModel model) { if (ModelState.IsValid) { if (_userProfileService.ChangePassword(model.UserProfilID, MD5Hashing.MD5Hash(model.Password))) { _forgetPasswordRequestService.InvalidateRequest(model.UserProfilID); } return(RedirectToAction("LogOn")); } return(View("ForgetPassword", model)); }
public async Task <IActionResult> ForgotPassword(Models.ForgotPasswordModel model) { if (ModelState.IsValid) { var user = await _userManager.FindByEmailAsync(model.Email); if (user != null) { var token = await _userManager.GeneratePasswordResetTokenAsync(user); var resetURL = Url.Action("ResetPassword", "Home", new { token = token, email = model.Email }, Request.Scheme); System.IO.File.WriteAllText("resetLink.txt", resetURL); return(View("Success")); } else { return(View()); } } return(View()); }
public async Task <ActionResult> ForgotPassword(Models.ForgotPasswordModel model) { if (WebSecurity.UserExists(model.EmailAddress)) { string resetToken = WebSecurity.GeneratePasswordResetToken(model.EmailAddress); string resetUrl = Request.Url.GetLeftPart(UriPartial.Authority) + "/Membership/Reset?resetToken=" + resetToken; string sendGridApiKey = ConfigurationManager.AppSettings["SendGrid.ApiKey"]; SendGrid.SendGridAPIClient client = new SendGrid.SendGridAPIClient(sendGridApiKey); Email from = new Email("*****@*****.**"); string subject = "Instructions for Resetting Your Password"; Email to = new Email(model.EmailAddress); Content content = new Content("text/html", string.Format("<a href=\"{0}\">Reset your password</a>", resetUrl)); Mail mail = new Mail(from, subject, to, content); var response = await client.client.mail.send.post(requestBody : mail.Get()); string message = await response.Body.ReadAsStringAsync(); } return(RedirectToAction("ResetSent")); }
public ActionResult ForgetPassword(string key) { BLL.ForgetPasswordRequest req = _forgetPasswordRequestService.GetValidRequest(key); if (req != null) { Models.ForgotPasswordModel model = new Models.ForgotPasswordModel(); model.UserProfilID = req.UserProfileID; return View("ForgetPassword", model); } return new EmptyResult(); }