Files
2024-05-21 12:10:53 +03:00

23 lines
621 B
C#

using Application.Services.Jwt;
using FluentValidation;
namespace Application.Endpoints.Authorization.RefreshToken;
public class RefreshJwtValidator : AbstractValidator<RefreshJwtCommand>
{
private readonly IJwtService _jwtService;
public RefreshJwtValidator(IJwtService jwtService)
{
_jwtService = jwtService;
RuleFor(x => x.Token)
.NotEmpty().WithMessage("Token is required.")
.Must(BeAValidToken).WithMessage("Token is invalid or expired.");
}
private bool BeAValidToken(string token)
{
return _jwtService.ValidateJwtToken(token);
}
}