Skip to content

Instantly share code, notes, and snippets.

@babaktaremi
Created August 22, 2021 10:35
Show Gist options
  • Save babaktaremi/0e770471df62788851f21fc7430bf498 to your computer and use it in GitHub Desktop.
Save babaktaremi/0e770471df62788851f21fc7430bf498 to your computer and use it in GitHub Desktop.
[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