-
-
Save Pownraj-2818/a1fd91b2cb8f190083f67ff73f652ea7 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
public async Task Verify(string otp) | |
{ | |
var account = _context.Users.SingleOrDefault(x => x.OTP == otp); | |
if (account == null) | |
{ | |
throw new BadHttpRequestException("Invalid verification OTP!"); | |
} | |
if (account.VerifiedAt != DateTime.MinValue) | |
{ | |
throw new BadHttpRequestException("Account already verified!"); | |
} | |
account.VerifiedAt = DateTime.Now; | |
account.IsVerified = true; | |
account.OTP = null; | |
account.OTPExpiresAt = DateTime.MinValue; | |
await _context.SaveChangesAsync(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment