using Application.Services.Jwt; namespace Application.Endpoints.Authorization.RefreshToken; public class RefreshJwtHandler(IJwtService jwtService) { public async Task Handle(RefreshJwtCommand command, CancellationToken cancellationToken) { var validator = new RefreshJwtValidator(jwtService); var validationResult = await validator.ValidateAsync(command, cancellationToken); if (!validationResult.IsValid) { var firstError = validationResult.Errors.FirstOrDefault(); return new BaseResponse { StatusCode = HttpStatusCodes.Unauthorized, Message = firstError?.ErrorMessage }; } var newToken = jwtService.RefreshToken(command.Token); return new BaseResponse { StatusCode = HttpStatusCodes.OK, Message = "Token refreshed successfully.", Data = newToken }; } }