26 lines
688 B
C#
26 lines
688 B
C#
using System.Security.Claims;
|
|
|
|
namespace Indotalent.ConfigFrontEnd.Extensions;
|
|
|
|
public static class IdentityClaimPrincipalExtension
|
|
{
|
|
public static string? GetUserId(this ClaimsPrincipal? user)
|
|
{
|
|
return user?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
|
|
}
|
|
|
|
public static string? GetEmail(this ClaimsPrincipal? user)
|
|
{
|
|
return user?.FindFirst(ClaimTypes.Email)?.Value;
|
|
}
|
|
|
|
public static string? GetUserName(this ClaimsPrincipal? user)
|
|
{
|
|
return user?.FindFirst(ClaimTypes.Name)?.Value;
|
|
}
|
|
|
|
public static string? GetFullName(this ClaimsPrincipal? user)
|
|
{
|
|
return user?.FindFirst(ClaimTypes.GivenName)?.Value;
|
|
}
|
|
} |