public ActionResult ForgotPassword(PasswordResetInfo model) { if (!_accountRepository.Exists(model.Email)) { ModelState.AddModelError(nameof(model.Email), UserDoesNotExistError); return(View(model)); } try { var newPassword = _accountRepository.RestorePassword(model.Email); _notificationService.SendPassword(model.Email, newPassword); return(this.InfoMessage(InfoMessage.Success(DictionaryPhraseRepository.Current.Get("/Accounts/Forgot Password/Reset Password Success", "Your password has been reset.")))); } catch (Exception ex) { Log.Error($"Can't reset password for user {model.Email}", ex, this); ModelState.AddModelError(nameof(model.Email), ex.Message); return(View(model)); } }
public ActionResult ForgotPassword(PasswordResetInfo model) { if (!this.accountRepository.Exists(model.Email)) { this.ModelState.AddModelError(nameof(model.Email), Errors.UserDoesNotExist); return(this.View(model)); } try { var newPassword = this.accountRepository.RestorePassword(model.Email); this.notificationService.SendPassword(model.Email, newPassword); return(this.InfoMessage(InfoMessage.Success(Captions.ResetPasswordSuccess))); } catch (Exception ex) { Log.Error($"Can't reset password for user {model.Email}", ex, this); this.ModelState.AddModelError(nameof(model.Email), ex.Message); return(this.View(model)); } }