Last active
November 6, 2018 23:55
-
-
Save evgomes/5dd7f6d1332f6eb91a0e7bcbc97a1698 to your computer and use it in GitHub Desktop.
Token creation method of JWT API.
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<TokenResponse> CreateAccessTokenAsync(string email, string password) | |
{ | |
var user = await _userService.FindByEmailAsync(email); | |
if (user == null || !_passwordHasher.PasswordMatches(password, user.Password)) | |
{ | |
return new TokenResponse(false, "Invalid credentials.", null); | |
} | |
var token = _tokenHandler.CreateAccessToken(user); | |
return new TokenResponse(true, null, token); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment