public async Task <IActionResult> ConfirmMailToken(ResetTokenMailDto resetTokenMailDto) { var model = await _businessServiceProvider.UserService.GenerateEmailConfirmationTokenAsync(resetTokenMailDto); await ConfirmMailSender(model.User, model.Token); return(Ok()); }
public async Task <IActionResult> ResetPasswordToken(ResetTokenMailDto resetTokenMailDto) { var token = await _businessServiceProvider.UserService.GeneratePasswordResetTokenAsync(resetTokenMailDto); var confirmLink = Url.ResetPasswordMailLink(resetTokenMailDto.Email, token, Request.Scheme); await _appEmailService.SendResetPasswordMailAsync(resetTokenMailDto.Email, confirmLink); return(Ok()); }
public async Task <string> GeneratePasswordResetTokenAsync(ResetTokenMailDto resetTokenMailDto) { await _userValidationService.ResetPasswordMailRule.ValidateAsync(resetTokenMailDto); var user = await _unitOfWork.UserRepository.FindByEmailAsync(resetTokenMailDto.Email); if (user == null) { throw new ArgumentNullException("Can not find user"); } if (user.EmailConfirmed == false) { throw new Exception("Email Confirm Error"); } var token = await _unitOfWork.UserRepository.UserManager.GeneratePasswordResetTokenAsync(user); if (token == null) { throw new ArgumentNullException("Token Null"); } return(token); }
public async Task <GenerateConfirmTokenDto> GenerateEmailConfirmationTokenAsync(ResetTokenMailDto resetTokenMailDto) { await _userValidationService.ResetPasswordMailRule.ValidateAsync(resetTokenMailDto); var user = await _unitOfWork.UserRepository.FindByEmailAsync(resetTokenMailDto.Email); if (user == null) { throw new ArgumentNullException("Can not find user"); } var token = await _unitOfWork.UserRepository.UserManager.GenerateEmailConfirmationTokenAsync(user); if (token == null) { throw new ArgumentNullException("Token Null"); } return(new GenerateConfirmTokenDto { Token = token, User = user }); }