|
1 | 1 | using Fin.Application.Authentications.Dtos; |
2 | 2 | using Fin.Application.Authentications.Enums; |
3 | | -using Fin.Application.Authentications.Utils; |
| 3 | +using Fin.Application.Emails; |
4 | 4 | using Fin.Application.Globals.Dtos; |
5 | 5 | using Fin.Application.Users.Services; |
6 | 6 | using Fin.Domain.Global; |
7 | | -using Fin.Domain.Tenants.Entities; |
8 | 7 | using Fin.Domain.Users.Dtos; |
9 | 8 | using Fin.Domain.Users.Entities; |
10 | 9 | using Fin.Infrastructure.Authentications; |
|
14 | 13 | using Fin.Infrastructure.AutoServices.Interfaces; |
15 | 14 | using Fin.Infrastructure.Constants; |
16 | 15 | using Fin.Infrastructure.Database.Repositories; |
17 | | -using Fin.Infrastructure.EmailSenders; |
18 | 16 | using Fin.Infrastructure.EmailSenders.Dto; |
19 | 17 | using Fin.Infrastructure.Redis; |
20 | 18 | using Microsoft.EntityFrameworkCore; |
@@ -59,6 +57,7 @@ public AuthenticationService( |
59 | 57 | _configuration = configuration; |
60 | 58 | _tokenService = tokenService; |
61 | 59 | _userCreateService = userCreateService; |
| 60 | + |
62 | 61 |
|
63 | 62 | var encryptKey = configuration.GetSection(AuthenticationConstants.EncryptKeyConfigKey).Value ?? ""; |
64 | 63 | var encryptIv = configuration.GetSection(AuthenticationConstants.EncryptIvConfigKey).Value ?? ""; |
@@ -90,26 +89,17 @@ public async Task SendResetPasswordEmail(SendResetPasswordEmailInput input) |
90 | 89 | var logoIconUrl = $"{frontUrl}/icons/fin.png"; |
91 | 90 | var resetLink = $"{frontUrl}/authentication/reset-password?token={token}"; |
92 | 91 |
|
93 | | - var subject = AuthenticationTemplates.ResetPasswordEmailSubject |
94 | | - .Replace("{{appName}}", AppConstants.AppName); |
95 | | - |
96 | | - var plainBody = AuthenticationTemplates.ResetPasswordEmailPlainTemplate |
97 | | - .Replace("{{appName}}", AppConstants.AppName) |
98 | | - .Replace("{{linkLifeTime}}", tokenLifeTimeInHours.ToString()) |
99 | | - .Replace("{{resetLink}}", resetLink); |
| 92 | + var parameters = new Dictionary<string, string>(); |
| 93 | + parameters.Add("appName", AppConstants.AppName); |
| 94 | + parameters.Add("linkLifeTime", tokenLifeTimeInHours.ToString()); |
| 95 | + parameters.Add("resetLink", resetLink); |
| 96 | + parameters.Add("logoIconUrl", logoIconUrl); |
100 | 97 |
|
101 | | - var htmlBody = AuthenticationTemplates.ResetPasswordEmailTemplate |
102 | | - .Replace("{{appName}}", AppConstants.AppName) |
103 | | - .Replace("{{logoIconUrl}}", logoIconUrl) |
104 | | - .Replace("{{linkLifeTime}}", tokenLifeTimeInHours.ToString()) |
105 | | - .Replace("{{resetLink}}", resetLink); |
106 | | - |
107 | 98 | await _emailSender.SendEmailAsync(new SendEmailDto |
108 | 99 | { |
109 | | - Subject = subject, |
| 100 | + BaseTemplatesName = "ResetPassword_", |
| 101 | + TemplateProperties = parameters, |
110 | 102 | ToEmail = input.Email, |
111 | | - PlainBody = plainBody, |
112 | | - HtmlBody = htmlBody, |
113 | 103 | ToName = credential.User.DisplayName |
114 | 104 | }); |
115 | 105 | } |
|
0 commit comments