UDT-002: Logout + Refresh Token con rotación y chain revocation #3

Merged
dmolinari merged 36 commits from feature/UDT-002 into main 2026-04-14 17:37:47 +00:00
3 changed files with 28 additions and 0 deletions
Showing only changes of commit 6c02197369 - Show all commits

View File

@@ -0,0 +1,3 @@
namespace SIGCM2.Application.Auth.Logout;
public sealed record LogoutCommand(int UsuarioId);

View File

@@ -0,0 +1,22 @@
using SIGCM2.Application.Abstractions;
using SIGCM2.Application.Abstractions.Persistence;
namespace SIGCM2.Application.Auth.Logout;
public sealed class LogoutCommandHandler : ICommandHandler<LogoutCommand, LogoutResponseDto>
{
private readonly IRefreshTokenRepository _refreshRepo;
public LogoutCommandHandler(IRefreshTokenRepository refreshRepo)
{
_refreshRepo = refreshRepo;
}
public async Task<LogoutResponseDto> Handle(LogoutCommand command)
{
// Revoke all active tokens for the user across all families.
// Idempotent: 0 rows affected is not an error.
await _refreshRepo.RevokeAllActiveForUserAsync(command.UsuarioId, DateTime.UtcNow);
return new LogoutResponseDto(true, "Sesión cerrada correctamente");
}
}

View File

@@ -0,0 +1,3 @@
namespace SIGCM2.Application.Auth.Logout;
public sealed record LogoutResponseDto(bool Success, string Mensaje);