Skip to content

Instantly share code, notes, and snippets.

@ntakouris
Created July 22, 2019 10:03
Show Gist options
  • Save ntakouris/de89c8c205bdaacf95e1770dc55f4f8a to your computer and use it in GitHub Desktop.
Save ntakouris/de89c8c205bdaacf95e1770dc55f4f8a to your computer and use it in GitHub Desktop.
public async Task<AuthenticationResult> LoginAsync(string email, string password)
{
var user = await _userManager.FindByEmailAsync(email);
if (user == null)
{
return new AuthenticationResult
{
Errors = new[] {"User does not exist"}
};
}
var userHasValidPassword = await _userManager.CheckPasswordAsync(user, password);
if (!userHasValidPassword)
{
return new AuthenticationResult
{
Errors = new[] {"User/password combination is wrong"}
};
}
return await GenerateAuthenticationResultForUserAsync(user);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment