2025-09-27 10:36:00 +03:30
|
|
|
using System.Security.Claims;
|
|
|
|
|
using FrontOffice.BFF.Application.Common.Interfaces;
|
|
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
|
|
|
|
|
|
namespace FrontOffice.BFF.WebApi.Common.Services;
|
|
|
|
|
|
|
|
|
|
public class CurrentUserService : ICurrentUserService
|
|
|
|
|
{
|
|
|
|
|
private readonly IHttpContextAccessor _httpContextAccessor;
|
|
|
|
|
|
|
|
|
|
public CurrentUserService(IHttpContextAccessor httpContextAccessor)
|
|
|
|
|
{
|
|
|
|
|
_httpContextAccessor = httpContextAccessor;
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-20 23:18:07 +03:30
|
|
|
public long? UserId => long?.Parse(_httpContextAccessor.HttpContext?.User?.FindFirstValue(ClaimTypes.NameIdentifier) ?? throw new InvalidOperationException());
|
2025-11-16 03:28:34 +03:30
|
|
|
public string? FirstName => _httpContextAccessor.HttpContext?.User?.FindFirstValue("FirstName");
|
|
|
|
|
public string? LastName => _httpContextAccessor.HttpContext?.User?.FindFirstValue("LastName");
|
|
|
|
|
public string? MobileNumber => _httpContextAccessor.HttpContext?.User?.FindFirstValue("MobileNumber");
|
2025-09-27 10:36:00 +03:30
|
|
|
}
|