using System.Security.Claims;

namespace Tiku.Application.Security;

public sealed class CurrentUser : ICurrentUser
{
    public Guid? UserId { get; private set; }
    public Guid? SessionId { get; private set; }
    public string? Phone { get; private set; }
    public string? Email { get; private set; }
    public bool IsAuthenticated { get; private set; }

    public void Load(ClaimsPrincipal principal)
    {
        IsAuthenticated = principal.Identity?.IsAuthenticated == true;
        UserId = principal.FindGuid(TikuClaimTypes.UserId);
        SessionId = principal.FindGuid(TikuClaimTypes.SessionId);
        Phone = principal.FindValue(TikuClaimTypes.Phone);
        Email = principal.FindValue(TikuClaimTypes.Email);
    }
}
