| | | 1 | | using ArturRios.Heimdall.Command.Services; |
| | | 2 | | using ArturRios.Messaging.Email; |
| | | 3 | | |
| | | 4 | | namespace ArturRios.Heimdall.WebApi.Email; |
| | | 5 | | |
| | | 6 | | /// <summary> |
| | | 7 | | /// Delivers UC-47's registration-attempt notice through Mailgun (AF-47b). A failure is logged by |
| | | 8 | | /// <see cref="MailgunSender" /> and never propagated. |
| | | 9 | | /// </summary> |
| | | 10 | | public class MailgunRegistrationAttemptSender( |
| | | 11 | | IEmailService emailService, |
| | | 12 | | ILogger<MailgunRegistrationAttemptSender> logger) |
| | 0 | 13 | | : MailgunSender(emailService, logger), IRegistrationAttemptSender |
| | | 14 | | { |
| | | 15 | | private const string Subject = "Someone tried to create an account with your address"; |
| | | 16 | | |
| | 0 | 17 | | protected override string Purpose => "registration attempt"; |
| | | 18 | | |
| | | 19 | | public Task SendAsync(string email, bool googleAccount) |
| | | 20 | | { |
| | 0 | 21 | | var instead = googleAccount |
| | 0 | 22 | | ? "Your account signs in with Google. Use \"Continue with Google\" to sign in." |
| | 0 | 23 | | : "Sign in with your password, or use \"Forgotten your password?\" if you no longer have it."; |
| | | 24 | | |
| | 0 | 25 | | var body = $""" |
| | 0 | 26 | | Someone tried to create a new account with this address. You already have one. |
| | 0 | 27 | | |
| | 0 | 28 | | If it was you: {instead} |
| | 0 | 29 | | |
| | 0 | 30 | | If it was not you, you do not need to do anything. Nothing about your account has changed. |
| | 0 | 31 | | """; |
| | | 32 | | |
| | 0 | 33 | | return DeliverAsync(email, Subject, body); |
| | | 34 | | } |
| | | 35 | | } |