diff options
| author | ivar <i@oiee.no> | 2023-11-12 00:01:31 +0100 |
|---|---|---|
| committer | ivar <i@oiee.no> | 2023-11-12 00:01:31 +0100 |
| commit | a9f9650400ed9e7f40db5ec5fd08a861f4c30902 (patch) | |
| tree | 7df4e6a086acc21a5b47b4fae8bf395f79061f29 /code/api/src/Services/EmailValidationService.cs | |
| parent | 854dedead3a3ed987997a0132f527db73b65b0ac (diff) | |
| download | greatoffice-a9f9650400ed9e7f40db5ec5fd08a861f4c30902.tar.xz greatoffice-a9f9650400ed9e7f40db5ec5fd08a861f4c30902.zip | |
Change how config is operated
Diffstat (limited to 'code/api/src/Services/EmailValidationService.cs')
| -rw-r--r-- | code/api/src/Services/EmailValidationService.cs | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/code/api/src/Services/EmailValidationService.cs b/code/api/src/Services/EmailValidationService.cs index c7be20a..5d909f3 100644 --- a/code/api/src/Services/EmailValidationService.cs +++ b/code/api/src/Services/EmailValidationService.cs @@ -8,29 +8,33 @@ public class EmailValidationService private readonly ILogger<EmailValidationService> _logger; private readonly string EmailValidationUrl; - public EmailValidationService(IStringLocalizer<SharedResources> localizer, MainAppDatabase database, MailService mailService, ILogger<EmailValidationService> logger, VaultService vaultService) { + public EmailValidationService(IStringLocalizer<SharedResources> localizer, MainAppDatabase database, MailService mailService, ILogger<EmailValidationService> logger) + { _localizer = localizer; _database = database; _mailService = mailService; _logger = logger; - var configuration = vaultService.GetCurrentAppConfiguration(); - EmailValidationUrl = configuration.CANONICAL_BACKEND_URL + "/_/validate"; + EmailValidationUrl = Program.AppConfiguration.CANONICAL_BACKEND_URL + "/_/validate"; } - public bool FulfillEmailValidationRequest(Guid id, Guid userId) { + public bool FulfillEmailValidationRequest(Guid id, Guid userId) + { var item = _database.ValidationEmails.FirstOrDefault(c => c.Id == id); - if (item == default) { + if (item == default) + { _logger.LogDebug("Did not find email validation request with id: {requestId}", id); return false; } - if (item.UserId != userId) { + if (item.UserId != userId) + { _logger.LogInformation("An unknown user tried to validate the email validation request {requestId}", id); return false; } var user = _database.Users.FirstOrDefault(c => c.Id == item.UserId); - if (user == default) { + if (user == default) + { _database.ValidationEmails.Remove(item); _database.SaveChanges(); _logger.LogInformation("Deleting request {requestId} because user does not exist anymore", id); @@ -45,12 +49,15 @@ public class EmailValidationService return true; } - public async Task SendValidationEmailAsync(User user) { - var queueItem = new ValidationEmail() { + public async Task SendValidationEmailAsync(User user) + { + var queueItem = new ValidationEmail() + { UserId = user.Id, Id = Guid.NewGuid() }; - var email = new MailService.PostmarkEmail() { + var email = new MailService.PostmarkEmail() + { To = user.Username, Subject = _localizer["Greatoffice Email Validation"], TextBody = _localizer[""" |
