Update front and config
This commit is contained in:
@@ -92,7 +92,6 @@ public class KaigenService : IKaigenService
|
||||
var requestPayload = new
|
||||
{
|
||||
requestId = requestId,
|
||||
walletAddress = walletAddress,
|
||||
debitAmount = debitAmount
|
||||
};
|
||||
|
||||
@@ -114,6 +113,13 @@ public class KaigenService : IKaigenService
|
||||
}
|
||||
|
||||
var result = await response.Content.ReadFromJsonAsync<KaigenResponse>(_jsonOptions);
|
||||
|
||||
if (result == null || !result.Success)
|
||||
{
|
||||
_logger.LogError("Debit request failed: {Message}", result?.Message ?? "Unknown error");
|
||||
throw new Exception($"Debit request failed: {result?.Message}");
|
||||
}
|
||||
|
||||
_logger.LogInformation(
|
||||
"Successfully debited {Amount} credits for user {UserName} (wallet: {WalletAddress})",
|
||||
debitAmount, user.Name, walletAddress);
|
||||
@@ -145,7 +151,6 @@ public class KaigenService : IKaigenService
|
||||
var requestPayload = new
|
||||
{
|
||||
requestId = requestId,
|
||||
walletAddress = walletAddress
|
||||
};
|
||||
|
||||
_logger.LogInformation(
|
||||
@@ -180,21 +185,21 @@ public class KaigenService : IKaigenService
|
||||
{
|
||||
// Create the auth token: "walletaddress-username"
|
||||
var authToken = $"{GetUserWalletAddress(user)}-{user.Name}";
|
||||
|
||||
|
||||
// Encrypt the auth token using AES-256-GCM
|
||||
var encryptedToken = CryptoHelpers.EncryptAesGcm(authToken, _settings.SecretKey);
|
||||
|
||||
|
||||
// Create Basic Auth header with the encrypted token
|
||||
var basicAuthString = $"{encryptedToken}:";
|
||||
var base64Auth = Convert.ToBase64String(Encoding.ASCII.GetBytes(basicAuthString));
|
||||
|
||||
|
||||
// Create a new request with the auth header
|
||||
var request = new HttpRequestMessage(HttpMethod.Put, url)
|
||||
{
|
||||
Content = JsonContent.Create(payload, options: _jsonOptions)
|
||||
};
|
||||
request.Headers.Authorization = new AuthenticationHeaderValue("Basic", base64Auth);
|
||||
|
||||
|
||||
return await _httpClient.SendAsync(request);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user