diff --git a/.idea/.idea.Fin-Backend/.idea/copilot.data.migration.ask.xml b/.idea/.idea.Fin-Backend/.idea/copilot.data.migration.ask.xml
new file mode 100644
index 0000000..7ef04e2
--- /dev/null
+++ b/.idea/.idea.Fin-Backend/.idea/copilot.data.migration.ask.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/.idea.Fin-Backend/.idea/copilot.data.migration.ask2agent.xml b/.idea/.idea.Fin-Backend/.idea/copilot.data.migration.ask2agent.xml
new file mode 100644
index 0000000..1f2ea11
--- /dev/null
+++ b/.idea/.idea.Fin-Backend/.idea/copilot.data.migration.ask2agent.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/.idea.Fin-Backend/.idea/copilot.data.migration.edit.xml b/.idea/.idea.Fin-Backend/.idea/copilot.data.migration.edit.xml
new file mode 100644
index 0000000..8648f94
--- /dev/null
+++ b/.idea/.idea.Fin-Backend/.idea/copilot.data.migration.edit.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/.idea.Fin-Backend/.idea/db-forest-config.xml b/.idea/.idea.Fin-Backend/.idea/db-forest-config.xml
new file mode 100644
index 0000000..454b8f6
--- /dev/null
+++ b/.idea/.idea.Fin-Backend/.idea/db-forest-config.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Fin-Backend.sln.DotSettings.user b/Fin-Backend.sln.DotSettings.user
index e037b2a..0a010a0 100644
--- a/Fin-Backend.sln.DotSettings.user
+++ b/Fin-Backend.sln.DotSettings.user
@@ -1,5 +1,6 @@
ForceIncluded
+ ForceIncluded
ForceIncluded
ForceIncluded
ForceIncluded
@@ -11,9 +12,12 @@
ForceIncluded
ForceIncluded
ForceIncluded
- <SessionState ContinuousTestingMode="0" IsActive="True" Name="All tests from Solution" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session">
+ <SessionState ContinuousTestingMode="0" Name="All tests from Solution" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session">
<Solution />
</SessionState>
+ <SessionState ContinuousTestingMode="0" IsActive="True" Name="MailSenderClientTest" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session">
+ <Project Location="/home/rafaelchicovis/git/fin-backend/Fin.Test" Presentation="<Fin.Test>" />
+</SessionState>
diff --git a/Fin.Api/appsettings.json b/Fin.Api/appsettings.json
index 10a640f..b2ab7e9 100644
--- a/Fin.Api/appsettings.json
+++ b/Fin.Api/appsettings.json
@@ -13,6 +13,12 @@
"Redis": "localhost:6379",
"Version": "EXEMPLE",
"EmailSender": {
+ "MailService": "MailKit",
+
+ "MailSenderApiKey": "EXEMPLE",
+ "MailSenderName": "FinApp Team",
+ "MailSenderAddress": "EXEMPLE",
+
"EmailAddress": "EXEMPLE",
"Password": "EXEMPLE"
},
diff --git a/Fin.Application/Authentications/Services/AuthenticationService.cs b/Fin.Application/Authentications/Services/AuthenticationService.cs
index a03487a..a056f6f 100644
--- a/Fin.Application/Authentications/Services/AuthenticationService.cs
+++ b/Fin.Application/Authentications/Services/AuthenticationService.cs
@@ -15,6 +15,7 @@
using Fin.Infrastructure.Constants;
using Fin.Infrastructure.Database.Repositories;
using Fin.Infrastructure.EmailSenders;
+using Fin.Infrastructure.EmailSenders.Dto;
using Fin.Infrastructure.Redis;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Caching.Distributed;
@@ -68,7 +69,7 @@ public AuthenticationService(
public async Task SendResetPasswordEmail(SendResetPasswordEmailInput input)
{
var encryptedEmail = _cryptoHelper.Encrypt(input.Email);
- var credential = _credentialRepository.Query()
+ var credential = _credentialRepository
.Include(c => c.User)
.FirstOrDefault(c => c.EncryptedEmail == encryptedEmail);
@@ -89,13 +90,28 @@ public async Task SendResetPasswordEmail(SendResetPasswordEmailInput input)
var logoIconUrl = $"{frontUrl}/icons/fin.png";
var resetLink = $"{frontUrl}/authentication/reset-password?token={token}";
- var body = AuthenticationTemplates.ResetPasswordEmailTempalte
+ var subject = AuthenticationTemplates.ResetPasswordEmailSubject
+ .Replace("{{appName}}", AppConstants.AppName);
+
+ var plainBody = AuthenticationTemplates.ResetPasswordEmailPlainTemplate
+ .Replace("{{appName}}", AppConstants.AppName)
+ .Replace("{{linkLifeTime}}", tokenLifeTimeInHours.ToString())
+ .Replace("{{resetLink}}", resetLink);
+
+ var htmlBody = AuthenticationTemplates.ResetPasswordEmailTemplate
.Replace("{{appName}}", AppConstants.AppName)
.Replace("{{logoIconUrl}}", logoIconUrl)
.Replace("{{linkLifeTime}}", tokenLifeTimeInHours.ToString())
.Replace("{{resetLink}}", resetLink);
- await _emailSender.SendEmailAsync(input.Email, "Fin - Reset Password", body);
+ await _emailSender.SendEmailAsync(new SendEmailDto
+ {
+ Subject = subject,
+ ToEmail = input.Email,
+ PlainBody = plainBody,
+ HtmlBody = htmlBody,
+ ToName = credential.User.DisplayName
+ });
}
public async Task> ResetPassword(ResetPasswordInput input)
@@ -117,7 +133,7 @@ public async Task> ResetPasswo
ErrorCode = ResetPasswordErrorCode.NotSamePassword
};
- var credential = await _credentialRepository.Query().FirstOrDefaultAsync(c => c.ResetToken == input.ResetToken);
+ var credential = await _credentialRepository.FirstOrDefaultAsync(c => c.ResetToken == input.ResetToken);
if (credential == null)
return new ValidationResultDto
{
@@ -156,7 +172,7 @@ public async Task LoginOrSingInWithGoogle(LoginWithGoogle
{
var encryptedEmail = _cryptoHelper.Encrypt(input.Email);
- var credential = _credentialRepository.Query()
+ var credential = _credentialRepository
.Include(c => c.User)
.ThenInclude(c => c.Tenants)
.FirstOrDefault(c => c.EncryptedEmail == encryptedEmail);
diff --git a/Fin.Application/Authentications/Utils/AuthenticationTemplates.cs b/Fin.Application/Authentications/Utils/AuthenticationTemplates.cs
index d2cfb29..c67ce2d 100644
--- a/Fin.Application/Authentications/Utils/AuthenticationTemplates.cs
+++ b/Fin.Application/Authentications/Utils/AuthenticationTemplates.cs
@@ -111,7 +111,18 @@ public static class AuthenticationTemplates