Skip to content

Instantly share code, notes, and snippets.

@hudsonmendes
Created May 12, 2018 11:53
Show Gist options
  • Save hudsonmendes/1cdcfff6213678a53fd3032794d6d9a4 to your computer and use it in GitHub Desktop.
Save hudsonmendes/1cdcfff6213678a53fd3032794d6d9a4 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);
return Failure();
}
private AuthenticationResult SuccessFor(UserEntity user)
{
return AuthenticationResult.Success(
user.Id,
user.DisplayName,
user.Email,
JwtTokenFor(user));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment