diff options
| author | ivarlovlie <git@ivarlovlie.no> | 2022-06-04 21:05:47 +0200 |
|---|---|---|
| committer | ivarlovlie <git@ivarlovlie.no> | 2022-06-04 21:13:00 +0200 |
| commit | cf9597de850de1ef721a35ad79ac67b9fdb9e1d4 (patch) | |
| tree | 4805de53a24bedd91238d6d306476b1921ccc0ad /server/src/Services/ForgotPasswordService.cs | |
| parent | fdbeffe78e5cd7393d28915189ec518a06b941f1 (diff) | |
| download | greatoffice-cf9597de850de1ef721a35ad79ac67b9fdb9e1d4.tar.xz greatoffice-cf9597de850de1ef721a35ad79ac67b9fdb9e1d4.zip | |
refactor: Use Vault to get configuration
Diffstat (limited to 'server/src/Services/ForgotPasswordService.cs')
| -rw-r--r-- | server/src/Services/ForgotPasswordService.cs | 14 |
1 files changed, 8 insertions, 6 deletions
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<AppConfiguration> _configuration; private readonly ILogger<ForgotPasswordService> _logger; public ForgotPasswordService( AppDbContext context, - IConfiguration configuration, + IOptions<AppConfiguration> configuration, ILogger<ForgotPasswordService> 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<string>(AppEnvironmentVariables.ACCOUNTS_URL); - var emailFromAddress = _configuration.GetValue<string>(AppEnvironmentVariables.EMAIL_FROM_ADDRESS); - var emailFromDisplayName = _configuration.GetValue<string>(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. |
