Created
August 22, 2021 10:35
-
-
Save babaktaremi/0e770471df62788851f21fc7430bf498 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
[HttpPost("Login")] | |
public async Task<IActionResult> Login(LoginViewModel model) | |
{ | |
var user = await _userManager.FindByNameAsync(model.UserName); | |
if (user is null) | |
return BadRequest("User Not Found"); | |
var passwordValidator = await _userManager.CheckPasswordAsync(user, model.Password); | |
if (!passwordValidator) | |
return BadRequest("Password is not valid"); | |
var token = await _jwtService.GenerateAsync(user); | |
return Ok(token); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment