| | | 1 | | using ArturRios.Heimdall.Command.Services; |
| | | 2 | | using ArturRios.Messaging.Email; |
| | | 3 | | |
| | | 4 | | namespace ArturRios.Heimdall.WebApi.Email; |
| | | 5 | | |
| | | 6 | | /// <summary> |
| | | 7 | | /// Delivers UC-36's two-factor email code as a real email through Mailgun (FR-2F-03). Registered |
| | | 8 | | /// in place of <see cref="LoggingTwoFactorEmailSender" /> whenever Mailgun is configured. |
| | | 9 | | /// </summary> |
| | | 10 | | public class MailgunTwoFactorEmailSender( |
| | | 11 | | IEmailService emailService, |
| | | 12 | | ILogger<MailgunTwoFactorEmailSender> logger) |
| | 0 | 13 | | : MailgunSender(emailService, logger), ITwoFactorEmailSender |
| | | 14 | | { |
| | | 15 | | private const string Subject = "Your two-factor authentication code"; |
| | | 16 | | |
| | 0 | 17 | | protected override string Purpose => "two-factor authentication code"; |
| | | 18 | | |
| | | 19 | | public Task SendAsync(string email, string code) |
| | | 20 | | { |
| | 0 | 21 | | var body = $""" |
| | 0 | 22 | | Your two-factor authentication code is: {code} |
| | 0 | 23 | | |
| | 0 | 24 | | This code expires in 10 minutes. If you didn't request this, you can ignore this |
| | 0 | 25 | | email — nothing has changed. |
| | 0 | 26 | | """; |
| | | 27 | | |
| | 0 | 28 | | return DeliverAsync(email, Subject, body); |
| | | 29 | | } |
| | | 30 | | } |