public ActionResult ForgotPassword(ForgotPassword model) { if (!ReCaptcha.Validate(ConfigurationManager.AppSettings["ReCAPTCHAKey"])) ModelState.AddModelError("CAPTCHA", "CAPTCHA is invalid."); if (!ModelState.IsValid) { return View(); } try { Service.RequestPasswordReset(model.Username, model.Email, AppConfig.HostAddress + Url.Action("ResetPassword", "User")); TempData.SetStatusMessage("Password reset message has been sent."); return RedirectToAction("Login"); } catch (UserNotFoundException) { ModelState.AddModelError("Username", "Username or email doesn't match."); return View(); } }
public ActionResult ForgotPassword(ForgotPassword model) { if (!ReCaptcha.Validate(ConfigurationManager.AppSettings["ReCAPTCHAKey"])) ModelState.AddModelError("CAPTCHA", ViewRes.User.ForgotPasswordStrings.CaptchaIsInvalid); if (!ModelState.IsValid) { return View(); } try { Data.RequestPasswordReset(model.Username, model.Email, AppConfig.HostAddress + Url.Action("ResetPassword", "User")); TempData.SetStatusMessage(ViewRes.User.ForgotPasswordStrings.MessageSent); return RedirectToAction("Login"); } catch (UserNotFoundException) { ModelState.AddModelError("Username", ViewRes.User.ForgotPasswordStrings.UsernameDoesNotMatch); return View(); } }