finalizare 1.0
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user