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;
    }

    public static string? GetTenantId(this ClaimsPrincipal? user)
    {
        return user?.FindFirst(ClaimTypes.GroupSid)?.Value;
    }
}