using Galaeth.Services.Constants;
using Galaeth.Services.Interfaces;
using Injectio.Attributes;
namespace Galaeth.ApiServer.Providers;
///
[RegisterScoped]
public class IdentityProvider : IIdentityProvider
{
///
/// Initializes a new instance of the class.
///
/// Instance of .
public IdentityProvider(IHttpContextAccessor httpContextAccessor)
{
var claims = httpContextAccessor.HttpContext?.User.Claims;
if (claims is not null)
{
UserId = claims.FirstOrDefault(c => c.Type == ClaimIds.UserId)?.Value;
}
}
///
/// User's id.
///
private string UserId { get; set; }
///
public string GetRequestingUserId()
{
return UserId;
}
}