using System.Security.Claims;

namespace Tiku.Application.Security;

internal static class ClaimsPrincipalExtensions
{
    public static string? FindValue(this ClaimsPrincipal principal, string claimType)
    {
        return principal.FindFirst(claimType)?.Value;
    }

    public static Guid? FindGuid(this ClaimsPrincipal principal, string claimType)
    {
        var value = principal.FindValue(claimType);
        return Guid.TryParse(value, out var guid) ? guid : null;
    }
}