void IAccountService.PasswordReset(PasswordResetParams parameters) { if (parameters == null) return; var userResetToken = _userResetTokenRepository.Query(o => o.Token == parameters.PasswordResetToken).SingleOrDefault(); if (userResetToken == null || !ValidatePasswordResetToken(userResetToken)) return; var user = _userRepository.Query(o => o.Id == userResetToken.UserId).SingleOrDefault(); if (user == null) throw new ArgumentNullException(string.Format("user")); user.Password = GetHashingPassword(parameters.NewPassword); UnitOfWork.Commit(); DeleteUserResetToken(userResetToken); }
public ActionResult PasswordReset(PasswordResetModel model) { if (ModelIsValid) { if (!Execute(() => _accountService.VerifyUserResetToken(model.Token))) return RedirectToAction<AccountController>(o => o.PasswordRecovery()); var parameters = new PasswordResetParams { PasswordResetToken = model.Token, NewPassword = model.NewPassword, SessionId = Session.SessionID, UserIp = Request.UserHostAddress, UserHostName = Request.UserHostName }; if (Execute(() => _accountService.PasswordReset(parameters))) return View(new PasswordResetModel { PasswordWasChanged = true }); } return View(model); }