Skip to content

Instantly share code, notes, and snippets.

@Pownraj-2818
Created August 19, 2022 07:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pownraj-2818/cb8ce2041d4f9474e275cdc13b9dc799 to your computer and use it in GitHub Desktop.
Save Pownraj-2818/cb8ce2041d4f9474e275cdc13b9dc799 to your computer and use it in GitHub Desktop.
public async Task ResetPassword(ResetPasswordRequest request)
{
var account = GetuserByOtp(request.Otp);
if (account == null || account.OTPExpiresAt < DateTime.Now)
{
throw new BadHttpRequestException("Invalid OTP");
}
account.PasswordHash = BCrypt.Net.BCrypt.HashPassword(request.Password);
account.PasswordResetAt = DateTime.Now;
account.OTP = null;
account.OTPExpiresAt = DateTime.MinValue;
_context.Users.Update(account);
await _context.SaveChangesAsync();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment