finalizare 1.0

This commit is contained in:
andrei-mihnea-cerbu
2024-05-21 12:10:53 +03:00
parent f7795f7519
commit 1cc1d34003
11268 changed files with 2102399 additions and 10909 deletions
@@ -0,0 +1,30 @@
using Application.Services.Jwt;
namespace Application.Endpoints.Authorization.RefreshToken;
public class RefreshJwtHandler(IJwtService jwtService)
{
public async Task<BaseResponse> 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
};
}
}