Skip to content

easyextensions ClaimsPrincipalExtensions

BigMakCode edited this page Aug 5, 2024 · 1 revision

ClaimsPrincipalExtensions Public class

Description

ClaimsPrincipal extensions.

Diagram

  flowchart LR
  classDef interfaceStyle stroke-dasharray: 5 5;
  classDef abstractStyle stroke-width:4px
  subgraph EasyExtensions
  EasyExtensions.ClaimsPrincipalExtensions[[ClaimsPrincipalExtensions]]
  end
Loading

Members

Methods

Public Static methods

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.

Details

Summary

ClaimsPrincipal extensions.

Methods

GetId

public static int GetId(ClaimsPrincipal user)
Arguments
Type Name Description
ClaimsPrincipal user User instance.
Summary

Get user id.

Returns

User id.

Exceptions
Name Description
KeyNotFoundException Throws when claim not found.

TryGetId

public static int TryGetId(ClaimsPrincipal user)
Arguments
Type Name Description
ClaimsPrincipal user User instance.
Summary

Try get user id.

Returns

User id, or 0 if not found.

GetRoles

public static IEnumerable<string> GetRoles(ClaimsPrincipal user, string rolePrefix)
Arguments
Type Name Description
ClaimsPrincipal user User instance.
string rolePrefix Role prefix, for example: "user-group-" prefix returns group like "user-group-admins"
Summary

Get user roles.

Returns

User roles.

Generated with ModularDoc

Clone this wiki locally