public ActionResult PasswordResetConfirm(AccountPasswordResetModel model) { return View(model); }
public ActionResult PasswordReset(AccountPasswordResetModel model) { // // TODO: Create new password, and email username and password to the user. // TODO: display confirmation message to the user // try { Account account = this.dataRepository.GetAccount(model.AccountNameOrEmail); if (account == null) { account = this.dataRepository.GetAccountForEmail(model.AccountNameOrEmail); } if (account != null) { // generate new password string newPassword = SecurityUtil.GenerateRandomPassword(6); SecurityUtil.EncryptedPassword encryptedPassword = SecurityUtil.GenerateEncryptedPassword(newPassword); account.Password = encryptedPassword.Password; account.PasswordSalt = encryptedPassword.PasswordSalt; this.dataRepository.Update(account); MailUtil.SendMail( Properties.Settings.Default.MailServer, Properties.Settings.Default.MailPort, Properties.Settings.Default.MailUsername, Properties.Settings.Default.MailPassword, Properties.Settings.Default.MailUsername, "Mersiv", account.Email, account.Name, "Mersiv Account Password Reset", "A password reset was requested for your account <b>" + account.Name + "</b>" + "<br/><br/>Your password has been reset: " + newPassword + System.Environment.NewLine + System.Environment.NewLine + "<br/><br/>" + Properties.Settings.Default.BaseUrl + "/users/login", true); // TODO: redirect user to confirmation message return RedirectToAction("PasswordResetConfirm", "Account", new { accountInfo = model.AccountNameOrEmail }); } else { // // TODO: if account is still NULL then display error message to user. // } } catch(Exception exception) { // // TODO: Logging? Recovery? // } return View(); }