Created
May 12, 2018 11:53
-
-
Save hudsonmendes/1cdcfff6213678a53fd3032794d6d9a4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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