using Heimdall.Application.Common; using Heimdall.Application.Services; using MediatR; using Microsoft.Extensions.Logging; namespace Heimdall.Application.Auth.Commands.Logout; public class LogoutHandler : IRequestHandler { private readonly IAuthSignInService _signInService; private readonly IAuthDataService _authData; private readonly ILogger _logger; public LogoutHandler( IAuthSignInService signInService, IAuthDataService authData, ILogger logger) { _signInService = signInService; _authData = authData; _logger = logger; } public async Task Handle(LogoutCommand request, CancellationToken ct) { _logger.LogInformation("Logout: UserId={UserId}", request.UserId); if (!string.IsNullOrEmpty(request.RefreshToken)) { await _authData.RevokeRefreshTokenAsync(request.RefreshToken, request.UserId, ct); } await _signInService.SignOutAsync(); return ServiceResult.Success(); } }