Last active
November 6, 2018 23:54
-
-
Save evgomes/54a3b702dff80afc1b6bfa346a217126 to your computer and use it in GitHub Desktop.
Get claims method from the token handler of JWT API.
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 IEnumerable<Claim> GetClaims(User user) | |
{ | |
var claims = new List<Claim> | |
{ | |
new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString()), | |
new Claim(JwtRegisteredClaimNames.Sub, user.Email) | |
}; | |
foreach (var userRole in user.UserRoles) | |
{ | |
claims.Add(new Claim(ClaimTypes.Role, userRole.Role.Name)); | |
} | |
return claims; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment