|
|
@@ -59,8 +59,9 @@ namespace Esim.Apis.Business
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- // Generate 6-digit OTP
|
|
|
- string otpCode = GenerateOtp();
|
|
|
+ // Generate 6-digit OTP (fixed 111111 for test account abc@gmail.com)
|
|
|
+ bool isTestAccount = request.email.ToLower() == "abc@gmail.com";
|
|
|
+ string otpCode = isTestAccount ? "111111" : GenerateOtp();
|
|
|
|
|
|
// Check if customer exists, if not create new
|
|
|
var customer = dbContext.CustomerInfos
|
|
|
@@ -122,61 +123,65 @@ namespace Esim.Apis.Business
|
|
|
dbContext.OtpVerifications.Add(otpVerification);
|
|
|
await dbContext.SaveChangesAsync();
|
|
|
|
|
|
- // Add to MESSAGE_QUEUE for background email sending
|
|
|
- // Resolve template content now so Worker only needs to send email
|
|
|
- string lang = CommonLogic.GetLanguage(httpRequest, request.lang);
|
|
|
- string templateCode = "OTP_LOGIN";
|
|
|
+ // Skip email sending for test account
|
|
|
+ if (!isTestAccount)
|
|
|
+ {
|
|
|
+ // Add to MESSAGE_QUEUE for background email sending
|
|
|
+ // Resolve template content now so Worker only needs to send email
|
|
|
+ string lang = CommonLogic.GetLanguage(httpRequest, request.lang);
|
|
|
+ string templateCode = "OTP_LOGIN";
|
|
|
|
|
|
- // Query template and get language-specific content
|
|
|
- var template = dbContext.MessageTemplates
|
|
|
- .FirstOrDefault(t => t.TemplateCode == templateCode && t.Status == true);
|
|
|
+ // Query template and get language-specific content
|
|
|
+ var template = dbContext.MessageTemplates
|
|
|
+ .FirstOrDefault(t => t.TemplateCode == templateCode && t.Status == true);
|
|
|
|
|
|
- if (template == null)
|
|
|
- {
|
|
|
- log.Error($"Template '{templateCode}' not found in MESSAGE_TEMPLATE");
|
|
|
- throw new Exception($"Email template '{templateCode}' not found");
|
|
|
- }
|
|
|
+ if (template == null)
|
|
|
+ {
|
|
|
+ log.Error($"Template '{templateCode}' not found in MESSAGE_TEMPLATE");
|
|
|
+ throw new Exception($"Email template '{templateCode}' not found");
|
|
|
+ }
|
|
|
|
|
|
- // Get subject based on language (fallback to default column if _LO/_EN is null)
|
|
|
- string emailSubject = lang == "en"
|
|
|
- ? (template.SubjectEn ?? template.Subject ?? "")
|
|
|
- : (template.SubjectLo ?? template.Subject ?? "");
|
|
|
-
|
|
|
- // Get content based on language (fallback to default column if _LO/_EN is null)
|
|
|
- string emailContent = lang == "en"
|
|
|
- ? (template.ContentEn ?? template.Content ?? "")
|
|
|
- : (template.ContentLo ?? template.Content ?? "");
|
|
|
-
|
|
|
- // Replace placeholders in content
|
|
|
- emailContent = emailContent
|
|
|
- .Replace("{{OTP_CODE}}", otpCode)
|
|
|
- .Replace("{{EXPIRE_MINUTES}}", otpExpireMinutes.ToString());
|
|
|
-
|
|
|
- // Replace placeholders in subject (if any)
|
|
|
- emailSubject = emailSubject
|
|
|
- .Replace("{{OTP_CODE}}", otpCode)
|
|
|
- .Replace("{{EXPIRE_MINUTES}}", otpExpireMinutes.ToString());
|
|
|
- var emailMessageID = (int)await Database.DbLogic.GenIdAsync(dbContext, "MESSAGE_QUEUE_SEQ");
|
|
|
- var emailMessage = new MessageQueue
|
|
|
- {
|
|
|
- Id = emailMessageID,
|
|
|
- MessageType = 1, // Email
|
|
|
- Recipient = request.email,
|
|
|
- Subject = emailSubject, // Pre-resolved subject
|
|
|
- Content = emailContent, // Pre-resolved content
|
|
|
- Priority = true, // High priority
|
|
|
- Status = 0, // Pending
|
|
|
- ScheduledAt = DateTime.Now,
|
|
|
- RetryCount = 0,
|
|
|
- MaxRetry = 3,
|
|
|
- CreatedBy = customerId,
|
|
|
- CreatedDate = DateTime.Now
|
|
|
- };
|
|
|
+ // Get subject based on language (fallback to default column if _LO/_EN is null)
|
|
|
+ string emailSubject = lang == "en"
|
|
|
+ ? (template.SubjectEn ?? template.Subject ?? "")
|
|
|
+ : (template.SubjectLo ?? template.Subject ?? "");
|
|
|
+
|
|
|
+ // Get content based on language (fallback to default column if _LO/_EN is null)
|
|
|
+ string emailContent = lang == "en"
|
|
|
+ ? (template.ContentEn ?? template.Content ?? "")
|
|
|
+ : (template.ContentLo ?? template.Content ?? "");
|
|
|
+
|
|
|
+ // Replace placeholders in content
|
|
|
+ emailContent = emailContent
|
|
|
+ .Replace("{{OTP_CODE}}", otpCode)
|
|
|
+ .Replace("{{EXPIRE_MINUTES}}", otpExpireMinutes.ToString());
|
|
|
+
|
|
|
+ // Replace placeholders in subject (if any)
|
|
|
+ emailSubject = emailSubject
|
|
|
+ .Replace("{{OTP_CODE}}", otpCode)
|
|
|
+ .Replace("{{EXPIRE_MINUTES}}", otpExpireMinutes.ToString());
|
|
|
+ var emailMessageID = (int)await Database.DbLogic.GenIdAsync(dbContext, "MESSAGE_QUEUE_SEQ");
|
|
|
+ var emailMessage = new MessageQueue
|
|
|
+ {
|
|
|
+ Id = emailMessageID,
|
|
|
+ MessageType = 1, // Email
|
|
|
+ Recipient = request.email,
|
|
|
+ Subject = emailSubject, // Pre-resolved subject
|
|
|
+ Content = emailContent, // Pre-resolved content
|
|
|
+ Priority = true, // High priority
|
|
|
+ Status = 0, // Pending
|
|
|
+ ScheduledAt = DateTime.Now,
|
|
|
+ RetryCount = 0,
|
|
|
+ MaxRetry = 3,
|
|
|
+ CreatedBy = customerId,
|
|
|
+ CreatedDate = DateTime.Now
|
|
|
+ };
|
|
|
|
|
|
- dbContext.MessageQueues.Add(emailMessage);
|
|
|
- await dbContext.SaveChangesAsync();
|
|
|
+ dbContext.MessageQueues.Add(emailMessage);
|
|
|
+ await dbContext.SaveChangesAsync();
|
|
|
+ }
|
|
|
|
|
|
- log.Info($"OTP generated for {request.email}: {otpCode} - Email queued");
|
|
|
+ log.Info($"OTP generated for {request.email}: {otpCode} - {(isTestAccount ? "Test account, no email sent" : "Email queued")}");
|
|
|
|
|
|
return ApiResponseHelper.BuildResponse(
|
|
|
log,
|