namespace FrontOffice.BFF.Application.UserCQ.Queries.GetUser; public class GetUserQueryHandler : IRequestHandler { private readonly IApplicationContractContext _context; private readonly ICurrentUserService _currentUserService; public GetUserQueryHandler(IApplicationContractContext context, ICurrentUserService currentUserService) { _context = context; _currentUserService = currentUserService; } public async Task Handle(GetUserQuery request, CancellationToken cancellationToken) { var userId = _currentUserService.UserId ?? throw new ForbiddenAccessException(); var response = await _context.User.GetUserAsync(request: new() { Id = userId }, cancellationToken: cancellationToken); var result = response.Adapt(); var getJwtToken = await _context.User.GetJwtTokenAsync(request: new() { Id = userId }, cancellationToken: cancellationToken); if(getJwtToken != null && !string.IsNullOrWhiteSpace(getJwtToken.Token)) result.Token = getJwtToken.Token; return result; } }