feat: add club membership contract signing and city services
This commit is contained in:
+47
@@ -0,0 +1,47 @@
|
||||
using FrontOffice.BFF.Application.Common.Interfaces;
|
||||
using Mapster;
|
||||
using MediatR;
|
||||
|
||||
namespace FrontOffice.BFF.Application.UserCQ.Commands.RefreshToken;
|
||||
|
||||
/// <summary>
|
||||
/// هندلر رفرش توکن - فراخوانی CMS برای دریافت توکن جدید
|
||||
/// </summary>
|
||||
public class RefreshTokenCommandHandler : IRequestHandler<RefreshTokenCommand, RefreshTokenResponseDto>
|
||||
{
|
||||
private readonly IApplicationContractContext _context;
|
||||
|
||||
public RefreshTokenCommandHandler(IApplicationContractContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<RefreshTokenResponseDto> Handle(RefreshTokenCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
var cmsRequest = new CMSMicroservice.Protobuf.Protos.User.RefreshTokenRequest
|
||||
{
|
||||
CurrentToken = request.CurrentToken
|
||||
};
|
||||
|
||||
var response = await _context.User.RefreshTokenAsync(cmsRequest, cancellationToken: cancellationToken);
|
||||
|
||||
return new RefreshTokenResponseDto
|
||||
{
|
||||
Token = response.Token,
|
||||
Success = response.Success,
|
||||
Message = response.Message
|
||||
};
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new RefreshTokenResponseDto
|
||||
{
|
||||
Success = false,
|
||||
Message = $"خطا در رفرش توکن: {ex.Message}",
|
||||
Token = string.Empty
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user