feat: Enhance SMS verification with new token handling and update API key
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 9m45s
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 9m45s
This commit is contained in:
@@ -13,5 +13,10 @@ public interface IKavenegarService
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// ارسال پیامک با قالب (VerifyLookup)
|
/// ارسال پیامک با قالب (VerifyLookup)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Task VerifyLookupAsync(string mobile, string token, string template = "Afrino");
|
Task VerifyLookupAsync(string mobile, string token, string template = "OTP");
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ارسال پیامک با قالب و توکن دوم (VerifyLookup) — مثلاً برای قراردادها
|
||||||
|
/// </summary>
|
||||||
|
Task VerifyLookupAsync(string mobile, string token, string token2, string template);
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -26,12 +26,12 @@ public class CreateNewOtpTokenEventHandler : INotificationHandler<CreateNewOtpTo
|
|||||||
{
|
{
|
||||||
var purpose = notification.Item.Purpose?.ToLowerInvariant();
|
var purpose = notification.Item.Purpose?.ToLowerInvariant();
|
||||||
|
|
||||||
// برای امضای قرارداد، پیامک ساده با GUID ارسال شود
|
// برای امضای قرارداد، از الگوی Sign-Contract با GUID به عنوان token2 استفاده شود
|
||||||
if ((purpose == "signcontract" || purpose == "signclubcontract")
|
if ((purpose == "signcontract" || purpose == "signclubcontract")
|
||||||
&& !string.IsNullOrEmpty(notification.SignGuid))
|
&& !string.IsNullOrEmpty(notification.SignGuid))
|
||||||
{
|
{
|
||||||
var message = $"کد تایید امضای قرارداد: {notification.PlainCode}\nشناسه قرارداد: {notification.SignGuid}";
|
await _kavenegarService.VerifyLookupAsync(
|
||||||
await _kavenegarService.SendAsync(notification.Item.Mobile, message);
|
notification.Item.Mobile, notification.PlainCode, notification.SignGuid, "Sign-Contract");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
+2
-3
@@ -72,11 +72,10 @@ public class CreateNewOtpTokenCommandHandler : IRequestHandler<CreateNewOtpToken
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// برای امضای قرارداد، شناسه GUID هم در پیامک ارسال شود
|
// برای امضای قرارداد، از الگوی Sign-Contract با GUID به عنوان token2 استفاده شود
|
||||||
if ((purpose == "signcontract" || purpose == "signclubcontract") && !string.IsNullOrEmpty(request.SignGuid))
|
if ((purpose == "signcontract" || purpose == "signclubcontract") && !string.IsNullOrEmpty(request.SignGuid))
|
||||||
{
|
{
|
||||||
var message = $"کد تایید امضای قرارداد: {code}\nشناسه قرارداد: {request.SignGuid}";
|
await _kavenegarService.VerifyLookupAsync(mobile, code, request.SignGuid, "Sign-Contract");
|
||||||
await _kavenegarService.SendAsync(mobile, message);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ public class KavenegarService : IKavenegarService
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public async Task VerifyLookupAsync(string mobile, string token, string template = "Afrino")
|
public async Task VerifyLookupAsync(string mobile, string token, string template = "OTP")
|
||||||
{
|
{
|
||||||
if (!_smsSettings.Enabled)
|
if (!_smsSettings.Enabled)
|
||||||
{
|
{
|
||||||
@@ -106,4 +106,41 @@ public class KavenegarService : IKavenegarService
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public async Task VerifyLookupAsync(string mobile, string token, string token2, string template)
|
||||||
|
{
|
||||||
|
if (!_smsSettings.Enabled)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("SMS is disabled. Skipping VerifyLookup to {Mobile}", mobile);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_kavenegarApi == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("⚠️ Kavenegar API not initialized, cannot send VerifyLookup");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await Task.Run(() =>
|
||||||
|
{
|
||||||
|
var result = _kavenegarApi.VerifyLookup(
|
||||||
|
receptor: mobile,
|
||||||
|
token: token,
|
||||||
|
token2: token2,
|
||||||
|
token3: "",
|
||||||
|
template: template);
|
||||||
|
|
||||||
|
_logger.LogInformation("📱 VerifyLookup SMS sent to {Mobile} with template {Template} (token2), MessageId: {MessageId}",
|
||||||
|
mobile, template, result.Messageid);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "❌ Kavenegar error sending VerifyLookup to {Mobile}: {Message}", mobile, ex.Message);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@
|
|||||||
"Sms": {
|
"Sms": {
|
||||||
"Enabled": true,
|
"Enabled": true,
|
||||||
"Provider": "Kavenegar",
|
"Provider": "Kavenegar",
|
||||||
"KavenegarApiKey": "497263626F32626A48685A6137524C4F78575A766E4C74694A556B79317648424964655030682B554545413D",
|
"KavenegarApiKey": "43676A4E786A6C50452F2F6252507939346A5145764B33566B456454374E657A614468706658656D6534593D",
|
||||||
"Sender": "1000001110100"
|
"Sender": "1000001110100"
|
||||||
},
|
},
|
||||||
"DayaPayment": {
|
"DayaPayment": {
|
||||||
|
|||||||
@@ -51,7 +51,7 @@
|
|||||||
"Sms": {
|
"Sms": {
|
||||||
"Enabled": true,
|
"Enabled": true,
|
||||||
"Provider": "Kavenegar",
|
"Provider": "Kavenegar",
|
||||||
"KavenegarApiKey": "497263626F32626A48685A6137524C4F78575A766E4C74694A556B79317648424964655030682B554545413D",
|
"KavenegarApiKey": "43676A4E786A6C50452F2F6252507939346A5145764B33566B456454374E657A614468706658656D6534593D",
|
||||||
"Sender": "1000001110100"
|
"Sender": "1000001110100"
|
||||||
},
|
},
|
||||||
"DayaPayment": {
|
"DayaPayment": {
|
||||||
|
|||||||
Reference in New Issue
Block a user