-
-
Save gdyrrahitis/2696d94c5de1e394090abc563fb9fee3 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
private async Task LoginAsync(User user) | |
{ | |
var claims = new List<Claim> | |
{ | |
new Claim(ClaimTypes.NameIdentifier, user.UserName), | |
new Claim(ClaimTypes.Name, user.UserName), | |
new Claim(ClaimTypes.GivenName, user.FirstName), | |
new Claim(ClaimTypes.Surname, user.Surname), | |
new Claim(ClaimTypes.Email, user.Email, ClaimValueTypes.Email), | |
new Claim(ClaimTypes.DateOfBirth, user.DateOfBirth.ToString("O"), ClaimValueTypes.Date) | |
}; | |
var identity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme); | |
var principal = new ClaimsPrincipal(identity); | |
await HttpContext.SignInAsync(principal); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment