From cf9597de850de1ef721a35ad79ac67b9fdb9e1d4 Mon Sep 17 00:00:00 2001 From: ivarlovlie Date: Sat, 4 Jun 2022 21:05:47 +0200 Subject: refactor: Use Vault to get configuration --- server/src/Services/ForgotPasswordService.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'server/src/Services/ForgotPasswordService.cs') diff --git a/server/src/Services/ForgotPasswordService.cs b/server/src/Services/ForgotPasswordService.cs index de38b29..e6b6acf 100644 --- a/server/src/Services/ForgotPasswordService.cs +++ b/server/src/Services/ForgotPasswordService.cs @@ -1,16 +1,18 @@ +using Microsoft.Extensions.Options; + namespace IOL.GreatOffice.Api.Services; public class ForgotPasswordService { private readonly AppDbContext _context; private readonly MailService _mailService; - private readonly IConfiguration _configuration; + private readonly IOptions _configuration; private readonly ILogger _logger; public ForgotPasswordService( AppDbContext context, - IConfiguration configuration, + IOptions configuration, ILogger logger, MailService mailService ) { @@ -57,9 +59,9 @@ public class ForgotPasswordService var request = new ForgotPasswordRequest(user); _context.ForgotPasswordRequests.Add(request); await _context.SaveChangesAsync(cancellationToken); - var accountsUrl = _configuration.GetValue(AppEnvironmentVariables.ACCOUNTS_URL); - var emailFromAddress = _configuration.GetValue(AppEnvironmentVariables.EMAIL_FROM_ADDRESS); - var emailFromDisplayName = _configuration.GetValue(AppEnvironmentVariables.EMAIL_FROM_DISPLAY_NAME); + var portalUrl = _configuration.Value.PORTAL_URL; + var emailFromAddress = _configuration.Value.EMAIL_FROM_ADDRESS; + var emailFromDisplayName = _configuration.Value.EMAIL_FROM_DISPLAY_NAME; var zonedExpirationDate = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(request.ExpirationDate, requestTz.Id); var message = new MailMessage { From = new MailAddress(emailFromAddress, emailFromDisplayName), @@ -72,7 +74,7 @@ Hi {user.Username} Go to the following link to set a new password. -{accountsUrl}/#/reset-password?id={request.Id} +{portalUrl}/#/reset-password?id={request.Id} The link expires at {zonedExpirationDate:yyyy-MM-dd hh:mm}. If you did not request a password reset, no action is required. -- cgit v1.3