From 1bd30ee34323f150c63fc537e0d131dca29dc4ef Mon Sep 17 00:00:00 2001 From: ivarlovlie Date: Sun, 5 Jun 2022 00:19:10 +0200 Subject: refactor: Implement caching in VaultService and use VaultService instead of IOptions --- server/src/Services/ForgotPasswordService.cs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'server/src/Services/ForgotPasswordService.cs') diff --git a/server/src/Services/ForgotPasswordService.cs b/server/src/Services/ForgotPasswordService.cs index e6b6acf..6874d37 100644 --- a/server/src/Services/ForgotPasswordService.cs +++ b/server/src/Services/ForgotPasswordService.cs @@ -1,23 +1,21 @@ -using Microsoft.Extensions.Options; - namespace IOL.GreatOffice.Api.Services; public class ForgotPasswordService { private readonly AppDbContext _context; private readonly MailService _mailService; - private readonly IOptions _configuration; + private readonly AppConfiguration _configuration; private readonly ILogger _logger; public ForgotPasswordService( AppDbContext context, - IOptions configuration, + VaultService vaultService, ILogger logger, MailService mailService ) { _context = context; - _configuration = configuration; + _configuration = vaultService.GetCurrentAppConfiguration(); _logger = logger; _mailService = mailService; } @@ -59,9 +57,9 @@ public class ForgotPasswordService var request = new ForgotPasswordRequest(user); _context.ForgotPasswordRequests.Add(request); await _context.SaveChangesAsync(cancellationToken); - var portalUrl = _configuration.Value.PORTAL_URL; - var emailFromAddress = _configuration.Value.EMAIL_FROM_ADDRESS; - var emailFromDisplayName = _configuration.Value.EMAIL_FROM_DISPLAY_NAME; + var portalUrl = _configuration.PORTAL_URL; + var emailFromAddress = _configuration.EMAIL_FROM_ADDRESS; + var emailFromDisplayName = _configuration.EMAIL_FROM_DISPLAY_NAME; var zonedExpirationDate = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(request.ExpirationDate, requestTz.Id); var message = new MailMessage { From = new MailAddress(emailFromAddress, emailFromDisplayName), -- cgit v1.3