-
Notifications
You must be signed in to change notification settings - Fork 0
easyextensions ClaimsPrincipalExtensions
BigMakCode edited this page Aug 5, 2024
·
1 revision
ClaimsPrincipal extensions.
flowchart LR
classDef interfaceStyle stroke-dasharray: 5 5;
classDef abstractStyle stroke-width:4px
subgraph EasyExtensions
EasyExtensions.ClaimsPrincipalExtensions[[ClaimsPrincipalExtensions]]
end
Returns | Name |
---|---|
int |
GetId (ClaimsPrincipal user)Get user id. |
IEnumerable <string > |
GetRoles (ClaimsPrincipal user, string rolePrefix)Get user roles. |
int |
TryGetId (ClaimsPrincipal user)Try get user id. |
ClaimsPrincipal extensions.
public static int GetId(ClaimsPrincipal user)
Type | Name | Description |
---|---|---|
ClaimsPrincipal |
user | User instance. |
Get user id.
User id.
Name | Description |
---|---|
KeyNotFoundException | Throws when claim not found. |
public static int TryGetId(ClaimsPrincipal user)
Type | Name | Description |
---|---|---|
ClaimsPrincipal |
user | User instance. |
Try get user id.
User id, or 0 if not found.
public static IEnumerable<string> GetRoles(ClaimsPrincipal user, string rolePrefix)
Type | Name | Description |
---|---|---|
ClaimsPrincipal |
user | User instance. |
string |
rolePrefix | Role prefix, for example: "user-group-" prefix returns group like "user-group-admins" |
Get user roles.
User roles.
Generated with ModularDoc