🐛 Fix send factor code in mail

This commit is contained in:
2025-09-01 23:25:50 +08:00
parent 216c72ea36
commit 352746a141

View File

@@ -28,6 +28,7 @@ public class AccountService(
EmailService mailer, EmailService mailer,
PusherService.PusherServiceClient pusher, PusherService.PusherServiceClient pusher,
IStringLocalizer<NotificationResource> localizer, IStringLocalizer<NotificationResource> localizer,
IStringLocalizer<EmailResource> emailLocalizer,
ICacheService cache, ICacheService cache,
ILogger<AccountService> logger, ILogger<AccountService> logger,
INatsConnection nats INatsConnection nats
@@ -432,12 +433,14 @@ public class AccountService(
.Where(c => c.Type == AccountContactType.Email) .Where(c => c.Type == AccountContactType.Email)
.Where(c => c.VerifiedAt != null) .Where(c => c.VerifiedAt != null)
.Where(c => c.IsPrimary) .Where(c => c.IsPrimary)
.Where(c => c.AccountId == account.Id)
.Include(c => c.Account) .Include(c => c.Account)
.FirstOrDefaultAsync(); .FirstOrDefaultAsync();
if (contact is null) if (contact is null)
{ {
logger.LogWarning( logger.LogWarning(
"Unable to send factor code to #{FactorId} with, due to no contact method was found..." "Unable to send factor code to #{FactorId} with, due to no contact method was found...",
factor.Id
); );
return; return;
} }
@@ -446,7 +449,7 @@ public class AccountService(
.SendTemplatedEmailAsync<Pages.Emails.VerificationEmail, VerificationEmailModel>( .SendTemplatedEmailAsync<Pages.Emails.VerificationEmail, VerificationEmailModel>(
account.Nick, account.Nick,
contact.Content, contact.Content,
localizer["VerificationEmail"], emailLocalizer["VerificationEmail"],
new VerificationEmailModel new VerificationEmailModel
{ {
Name = account.Name, Name = account.Name,