Skip to content

Instantly share code, notes, and snippets.

@hudsonmendes
Created May 12, 2018 11:55
Show Gist options
  • Save hudsonmendes/4b820f0f927ecdc0aa52ef6b6b5dd85b to your computer and use it in GitHub Desktop.
Save hudsonmendes/4b820f0f927ecdc0aa52ef6b6b5dd85b to your computer and use it in GitHub Desktop.
public async Task<AuthenticationResult> Authenticate(Credentials credentials)
{
var user = await SignInManager.UserManager.FindByEmailAsync(credentials.EmailAddress);
var signIn = await SignInManager.CheckPasswordSignInAsync(user, credentials.Password, false);
if (signIn.Succeeded)
return SuccessFor(user, JwtTokenFor(user));
return Failure();
}
private AuthenticationResult SuccessFor(UserEntity user, string token)
{
return AuthenticationResult.Success(
user.Id,
user.DisplayName,
user.Email,
token);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment