public ActionResult Forgotten(string Email) { var user = _userService.SetResetToken(Email, UserType.Customer); if (user != null) { _notifyService.ResetPassword(user); } return(RedirectToAction("Sended", new { to = Email })); }
public ActionResult Forgotten(string Email) { if (Email.IsNotNullAndWhiteSpace()) { var user = _userService.SetResetToken(Email, UserType.Customer); if (user != null) { _notifyService.ResetPassword(user); } return(RedirectToAction("Sended", new { to = Email, status = (user != null ? 1 : 2) })); } return(RedirectToAction("Forgotten")); }
public ActionResult Forgotten(ForgottenViewModel model) { if (ModelState.IsValid) { var user = _userService.SetResetToken(model.Email, model.UserType); if (user != null) { _notifyService.ResetPassword(user); } return(RedirectToAction("Sended", "Account", new { to = model.Email, status = (user != null ? 1 : 2) })); } return(RedirectToAction("Forgotten", "Account")); }
public async Task ResetPassword(ResetPasswordRequest model) { var existing = await _userClaimService.GetByToken(model.VerificationCode); if (existing == null) { throw new NotFoundException(); } existing.IsClaimed = true; if (model.Password != model.RetypePassword) { throw new ValidationErrorException(); } existing.User.Password = _encryptionUtil.Encrypt(model.Password); existing.User.PasswordChangedAt = DateTime.UtcNow; var user = await _userService.Update(existing.User); await _userClaimService.Update(existing); var updatedUser = _mapper.Map <IUser>(user); await _notifyService.ResetPassword(updatedUser); }