-
-
Save DeebiKaaRaviSankar/374ad4f1674ece33d48d0e34269cae75 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[AllowAnonymous] | |
[HttpPost(DbConstants.Route_ForgotPassword)] | |
public async Task<IActionResult> ForgotPassword(EmailRequestDTO request) | |
{ | |
_user = await _userRepo.GetUser(email: request.email); | |
if (_user == null) return BadRequest(new { error = "User not found" }); | |
_user.ResetToken = _controllerService.GenerateOTP(_user, OTPLength: 6); | |
_user.ResetTokenExpires = DateTime.Now.AddMinutes(5); | |
_userRepo.UpdateUser(_user); | |
_emailContent.To = request.email; | |
_emailContent.Subject = "Reset your Password"; | |
_emailContent.Body = _controllerService.OtpMailBody(_user.ResetToken, 5); | |
_emailService.SendEmail(_emailContent); | |
return Ok("Check your mail"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment