public ActionResult PasswordRecoveryConfirmPOST(string token, string email, PasswordRecoveryConfirmModel model) { var account = _accountService.GetAccountByEmail(email); if (account == null) return RedirectToRoute("HomePage"); var cPrt = account.GetAttribute<string>(SystemAttributeNames.PasswordRecoveryToken); if (String.IsNullOrEmpty(cPrt)) return RedirectToRoute("HomePage"); if (!cPrt.Equals(token, StringComparison.InvariantCultureIgnoreCase)) return RedirectToRoute("HomePage"); if (ModelState.IsValid) { var response = _accountRegistrationService.ChangePassword(new ChangePasswordRequest(email, false, _accountSettings.DefaultPasswordFormat, model.NewPassword)); if (response.Success) { _genericAttributeService.SaveAttribute(account, SystemAttributeNames.PasswordRecoveryToken, ""); model.SuccessfullyChanged = true; model.Result = _localizationService.GetResource("Account.PasswordRecovery.PasswordHasBeenChanged"); //Đã thay đổi mật khẩu thành công! } else { model.Result = response.Errors.FirstOrDefault(); } return View(model); } //If we got this far, something failed, redisplay form return View(model); }
public ActionResult PasswordRecoveryConfirm(string token, string email) { var account = _accountService.GetAccountByEmail(email); if (account == null) return RedirectToRoute("HomePage"); var cPrt = account.GetAttribute<string>(SystemAttributeNames.PasswordRecoveryToken); if (String.IsNullOrEmpty(cPrt)) return RedirectToRoute("HomePage"); if (!cPrt.Equals(token, StringComparison.InvariantCultureIgnoreCase)) return RedirectToRoute("HomePage"); var model = new PasswordRecoveryConfirmModel(); return View(model); }