Created
March 24, 2019 19:35
-
-
Save Mirch/ceb7d4491ab4fbcb62e3855b8969ee61 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 IActionResult Login([FromBody]UserCredentials credentials) | |
{ | |
var user = _context.Users.SingleOrDefault(u => u.Email == credentials.Email); | |
if (user != null) | |
{ | |
var hashedPassword = _hashingService.Hash(credentials.Password, user.Salt); | |
if (hashedPassword == user.HashedPassword) | |
{ | |
return Ok(BuildToken(user.Email)); | |
} | |
} | |
return BadRequest("Could not login."); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment