Last active
November 6, 2018 23:55
-
-
Save evgomes/8ee5a8007e0649feddbe4a8462e97d69 to your computer and use it in GitHub Desktop.
Login endpoint 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
[Route("/api/login")] | |
[HttpPost] | |
public async Task<IActionResult> LoginAsync([FromBody] UserCredentialsResource userCredentials) | |
{ | |
if (!ModelState.IsValid) | |
{ | |
return BadRequest(ModelState); | |
} | |
var response = await _authenticationService.CreateAccessTokenAsync(userCredentials.Email, userCredentials.Password); | |
if(!response.Success) | |
{ | |
return BadRequest(response.Message); | |
} | |
var accessTokenResource = _mapper.Map<AccessToken, AccessTokenResource>(response.Token); | |
return Ok(accessTokenResource); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment