using LiteCqrs;
using TeleWave.Application.Common.Interfaces;
using TeleWave.Application.Common.Models;

namespace TeleWave.Application.Auth.Logout;

public sealed class LogoutCommandHandler(IRefreshTokenService refreshTokenService)
    : ICommandHandler<LogoutCommand, Result>
{
    public async Task<Result> Handle(LogoutCommand command, CancellationToken cancellationToken)
    {
        await refreshTokenService.RevokeAsync(command.RawToken, cancellationToken);
        return Result.Success();
    }
}
