diff --git a/backend/API/Controllers/DoctorsController.cs b/backend/API/Controllers/DoctorsController.cs index 43df1d7..d94877e 100644 --- a/backend/API/Controllers/DoctorsController.cs +++ b/backend/API/Controllers/DoctorsController.cs @@ -5,6 +5,7 @@ using Application.Endpoints.Doctors.Registration; using Application.Endpoints.Doctors.ResetPassword; using Application.Services.Database.MongoDB; using Application.Services.Database.PostgreSQL; +using Application.Services.Email; using Application.Services.HashingAlgorithms; using Application.Services.Jwt; using Core.Entities; @@ -20,14 +21,16 @@ public class DoctorsController : ControllerBase private readonly IDoctorRepository _database; private readonly IHashingAlgorithms _hashingAlgorithms; private readonly IJwtService _jwtService; + private readonly IEmailService _emailService; public DoctorsController(IDoctorRepository database, IHashingAlgorithms hashingAlgorithms, - IJwtService jwtService, IAppointmentsMongoDbService appointmentsMongoDbService) + IJwtService jwtService, IAppointmentsMongoDbService appointmentsMongoDbService, IEmailService emailService) { _database = database; _hashingAlgorithms = hashingAlgorithms; _jwtService = jwtService; _appointmentsMongoDbService = appointmentsMongoDbService; + _emailService = emailService; } [HttpPost("register")] @@ -35,6 +38,14 @@ public class DoctorsController : ControllerBase { var handler = new DoctorRegistrationHandler(_database, _hashingAlgorithms); var response = await handler.Handle(doctorRegistrationDto).ConfigureAwait(false); + + if (response.StatusCode < HttpStatusCodes.BadRequest) + { + var body = _emailService.GenerateCredentialsEmailBody( + doctorRegistrationDto.Email, doctorRegistrationDto.Password); + await _emailService.SendEmailAsync(doctorRegistrationDto.Email, "Successful registration!", body); + } + return StatusCode(response.StatusCode, response); } diff --git a/backend/API/Controllers/PatientsController.cs b/backend/API/Controllers/PatientsController.cs index bcca422..6b6850b 100644 --- a/backend/API/Controllers/PatientsController.cs +++ b/backend/API/Controllers/PatientsController.cs @@ -5,7 +5,9 @@ using Application.Endpoints.Patients.Registration; using Application.Endpoints.Patients.ResetPassword; using Application.Services.Database.PostgreSQL; using Application.Services.HashingAlgorithms; +using Application.Services.Email; using Application.Services.Jwt; +using Core.Entities; using Microsoft.AspNetCore.Mvc; namespace API.Controllers; @@ -18,14 +20,16 @@ public class PatientsController : ControllerBase private readonly IJwtService _jwtService; private readonly IMedicalHistoryRepository _medicalHistory; private readonly IPatientRepository _patientRepository; + private readonly IEmailService _emailService; public PatientsController(IPatientRepository patientRepository, IHashingAlgorithms hashingAlgorithms, - IJwtService jwtService, IMedicalHistoryRepository medicalHistory) + IJwtService jwtService, IMedicalHistoryRepository medicalHistory, IEmailService emailService) { _patientRepository = patientRepository; _hashingAlgorithms = hashingAlgorithms; _jwtService = jwtService; _medicalHistory = medicalHistory; + _emailService = emailService; } [HttpGet] @@ -97,6 +101,14 @@ public class PatientsController : ControllerBase { var handler = new PatientRegistrationHandler(_patientRepository, _hashingAlgorithms); var response = await handler.Handle(patientRegistrationDto).ConfigureAwait(false); + + if (response.StatusCode < HttpStatusCodes.BadRequest) + { + var body = _emailService.GenerateCredentialsEmailBody( + patientRegistrationDto.Email, patientRegistrationDto.Password); + await _emailService.SendEmailAsync(patientRegistrationDto.Email, "Successful registration!", body); + } + return StatusCode(response.StatusCode, response); } diff --git a/backend/API/appsettings.json b/backend/API/appsettings.json index 37e85cd..a18d26e 100644 --- a/backend/API/appsettings.json +++ b/backend/API/appsettings.json @@ -24,6 +24,14 @@ "Audience": "HealthCareManagerUsers", "ExpirationTime": 1440 }, + "SmtpSettings": { + "Host": "smtp-relay.brevo.com", + "Port": 587, + "From": "bot@healthcaremanager.com", + "EnableSSL": false, + "UserName": "andreimihneacerbu@gmail.com", + "Password": "zpK3w71LkNa0sGt6" + }, "AllowedHosts": "*", "Kestrel": { "Endpoints": { diff --git a/backend/API/bin/Debug/net8.0/API.dll b/backend/API/bin/Debug/net8.0/API.dll index 1f822a7..72b9964 100644 Binary files a/backend/API/bin/Debug/net8.0/API.dll and b/backend/API/bin/Debug/net8.0/API.dll differ diff --git a/backend/API/bin/Debug/net8.0/API.exe b/backend/API/bin/Debug/net8.0/API.exe index e4f149c..79b023a 100644 Binary files a/backend/API/bin/Debug/net8.0/API.exe and b/backend/API/bin/Debug/net8.0/API.exe differ diff --git a/backend/API/bin/Debug/net8.0/API.pdb b/backend/API/bin/Debug/net8.0/API.pdb index 1f8e859..9491066 100644 Binary files a/backend/API/bin/Debug/net8.0/API.pdb and b/backend/API/bin/Debug/net8.0/API.pdb differ diff --git a/backend/API/bin/Debug/net8.0/Application.dll b/backend/API/bin/Debug/net8.0/Application.dll index f11d862..d5f2864 100644 Binary files a/backend/API/bin/Debug/net8.0/Application.dll and b/backend/API/bin/Debug/net8.0/Application.dll differ diff --git a/backend/API/bin/Debug/net8.0/Application.pdb b/backend/API/bin/Debug/net8.0/Application.pdb index 719663b..598c982 100644 Binary files a/backend/API/bin/Debug/net8.0/Application.pdb and b/backend/API/bin/Debug/net8.0/Application.pdb differ diff --git a/backend/API/bin/Debug/net8.0/Core.dll b/backend/API/bin/Debug/net8.0/Core.dll index 8225300..2d5ca28 100644 Binary files a/backend/API/bin/Debug/net8.0/Core.dll and b/backend/API/bin/Debug/net8.0/Core.dll differ diff --git a/backend/API/bin/Debug/net8.0/Core.pdb b/backend/API/bin/Debug/net8.0/Core.pdb index 06c7fc0..07208af 100644 Binary files a/backend/API/bin/Debug/net8.0/Core.pdb and b/backend/API/bin/Debug/net8.0/Core.pdb differ diff --git a/backend/API/bin/Debug/net8.0/Infrastructure.dll b/backend/API/bin/Debug/net8.0/Infrastructure.dll index 6a14d5d..415c18b 100644 Binary files a/backend/API/bin/Debug/net8.0/Infrastructure.dll and b/backend/API/bin/Debug/net8.0/Infrastructure.dll differ diff --git a/backend/API/bin/Debug/net8.0/Infrastructure.pdb b/backend/API/bin/Debug/net8.0/Infrastructure.pdb index ffcc07d..394efdf 100644 Binary files a/backend/API/bin/Debug/net8.0/Infrastructure.pdb and b/backend/API/bin/Debug/net8.0/Infrastructure.pdb differ diff --git a/backend/API/bin/Debug/net8.0/appsettings.json b/backend/API/bin/Debug/net8.0/appsettings.json index 37e85cd..a18d26e 100644 --- a/backend/API/bin/Debug/net8.0/appsettings.json +++ b/backend/API/bin/Debug/net8.0/appsettings.json @@ -24,6 +24,14 @@ "Audience": "HealthCareManagerUsers", "ExpirationTime": 1440 }, + "SmtpSettings": { + "Host": "smtp-relay.brevo.com", + "Port": 587, + "From": "bot@healthcaremanager.com", + "EnableSSL": false, + "UserName": "andreimihneacerbu@gmail.com", + "Password": "zpK3w71LkNa0sGt6" + }, "AllowedHosts": "*", "Kestrel": { "Endpoints": { diff --git a/backend/API/obj/Debug/net8.0/API.AssemblyInfo.cs b/backend/API/obj/Debug/net8.0/API.AssemblyInfo.cs index 28c6995..9b04666 100644 --- a/backend/API/obj/Debug/net8.0/API.AssemblyInfo.cs +++ b/backend/API/obj/Debug/net8.0/API.AssemblyInfo.cs @@ -13,7 +13,7 @@ using System.Reflection; [assembly: System.Reflection.AssemblyCompanyAttribute("API")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] -[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+015a1a9c09fe601a8c8b9f61de5c7d87b5a73607")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+0d03c0ea4308c032d708d3ee63f648b10811c65f")] [assembly: System.Reflection.AssemblyProductAttribute("API")] [assembly: System.Reflection.AssemblyTitleAttribute("API")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] diff --git a/backend/API/obj/Debug/net8.0/API.AssemblyInfoInputs.cache b/backend/API/obj/Debug/net8.0/API.AssemblyInfoInputs.cache index 5f3a9b2..b171701 100644 --- a/backend/API/obj/Debug/net8.0/API.AssemblyInfoInputs.cache +++ b/backend/API/obj/Debug/net8.0/API.AssemblyInfoInputs.cache @@ -1 +1 @@ -fe88730eccbbece1fca0539b2a9e626db000fc875172a108baa980cc6e2addff +9da6326faa16b70419b8bad27961193604ad75fcbf0f437bde7752d1858a93b2 diff --git a/backend/API/obj/Debug/net8.0/API.csproj.AssemblyReference.cache b/backend/API/obj/Debug/net8.0/API.csproj.AssemblyReference.cache index 9ef3e87..cea7f2d 100644 Binary files a/backend/API/obj/Debug/net8.0/API.csproj.AssemblyReference.cache and b/backend/API/obj/Debug/net8.0/API.csproj.AssemblyReference.cache differ diff --git a/backend/API/obj/Debug/net8.0/API.dll b/backend/API/obj/Debug/net8.0/API.dll index 1f822a7..72b9964 100644 Binary files a/backend/API/obj/Debug/net8.0/API.dll and b/backend/API/obj/Debug/net8.0/API.dll differ diff --git a/backend/API/obj/Debug/net8.0/API.pdb b/backend/API/obj/Debug/net8.0/API.pdb index 1f8e859..9491066 100644 Binary files a/backend/API/obj/Debug/net8.0/API.pdb and b/backend/API/obj/Debug/net8.0/API.pdb differ diff --git a/backend/API/obj/Debug/net8.0/API.sourcelink.json b/backend/API/obj/Debug/net8.0/API.sourcelink.json index 27ac5fa..6807585 100644 --- a/backend/API/obj/Debug/net8.0/API.sourcelink.json +++ b/backend/API/obj/Debug/net8.0/API.sourcelink.json @@ -1 +1 @@ -{"documents":{"C:\\Users\\Andrei Cerbu\\Documents\\FACULTATE\\CC-FinalProj\\*":"https://raw.githubusercontent.com/andrei-mihnea-cerbu/CC-FinalProj/015a1a9c09fe601a8c8b9f61de5c7d87b5a73607/*"}} \ No newline at end of file +{"documents":{"C:\\Users\\Andrei Cerbu\\Documents\\FACULTATE\\CC-FinalProj\\*":"https://raw.githubusercontent.com/andrei-mihnea-cerbu/CC-FinalProj/0d03c0ea4308c032d708d3ee63f648b10811c65f/*"}} \ No newline at end of file diff --git a/backend/API/obj/Debug/net8.0/apphost.exe b/backend/API/obj/Debug/net8.0/apphost.exe index e4f149c..79b023a 100644 Binary files a/backend/API/obj/Debug/net8.0/apphost.exe and b/backend/API/obj/Debug/net8.0/apphost.exe differ diff --git a/backend/API/obj/Debug/net8.0/ref/API.dll b/backend/API/obj/Debug/net8.0/ref/API.dll index 69c05b4..9b0aa25 100644 Binary files a/backend/API/obj/Debug/net8.0/ref/API.dll and b/backend/API/obj/Debug/net8.0/ref/API.dll differ diff --git a/backend/API/obj/Debug/net8.0/refint/API.dll b/backend/API/obj/Debug/net8.0/refint/API.dll index 69c05b4..9b0aa25 100644 Binary files a/backend/API/obj/Debug/net8.0/refint/API.dll and b/backend/API/obj/Debug/net8.0/refint/API.dll differ diff --git a/backend/Application/Services/Email/IEmailService.cs b/backend/Application/Services/Email/IEmailService.cs new file mode 100644 index 0000000..570dddb --- /dev/null +++ b/backend/Application/Services/Email/IEmailService.cs @@ -0,0 +1,7 @@ +namespace Application.Services.Email; + +public interface IEmailService +{ + Task SendEmailAsync(string to, string subject, string body); + string GenerateCredentialsEmailBody(string email, string password); +} diff --git a/backend/Application/bin/Debug/net8.0/Application.dll b/backend/Application/bin/Debug/net8.0/Application.dll index f11d862..d5f2864 100644 Binary files a/backend/Application/bin/Debug/net8.0/Application.dll and b/backend/Application/bin/Debug/net8.0/Application.dll differ diff --git a/backend/Application/bin/Debug/net8.0/Application.pdb b/backend/Application/bin/Debug/net8.0/Application.pdb index 719663b..598c982 100644 Binary files a/backend/Application/bin/Debug/net8.0/Application.pdb and b/backend/Application/bin/Debug/net8.0/Application.pdb differ diff --git a/backend/Application/bin/Debug/net8.0/Core.dll b/backend/Application/bin/Debug/net8.0/Core.dll index 8225300..2d5ca28 100644 Binary files a/backend/Application/bin/Debug/net8.0/Core.dll and b/backend/Application/bin/Debug/net8.0/Core.dll differ diff --git a/backend/Application/bin/Debug/net8.0/Core.pdb b/backend/Application/bin/Debug/net8.0/Core.pdb index 06c7fc0..07208af 100644 Binary files a/backend/Application/bin/Debug/net8.0/Core.pdb and b/backend/Application/bin/Debug/net8.0/Core.pdb differ diff --git a/backend/Application/obj/Debug/net8.0/Application.AssemblyInfo.cs b/backend/Application/obj/Debug/net8.0/Application.AssemblyInfo.cs index 447ece1..1a3520f 100644 --- a/backend/Application/obj/Debug/net8.0/Application.AssemblyInfo.cs +++ b/backend/Application/obj/Debug/net8.0/Application.AssemblyInfo.cs @@ -13,7 +13,7 @@ using System.Reflection; [assembly: System.Reflection.AssemblyCompanyAttribute("Application")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] -[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+015a1a9c09fe601a8c8b9f61de5c7d87b5a73607")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+0d03c0ea4308c032d708d3ee63f648b10811c65f")] [assembly: System.Reflection.AssemblyProductAttribute("Application")] [assembly: System.Reflection.AssemblyTitleAttribute("Application")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] diff --git a/backend/Application/obj/Debug/net8.0/Application.AssemblyInfoInputs.cache b/backend/Application/obj/Debug/net8.0/Application.AssemblyInfoInputs.cache index e4ddb30..4c8a9af 100644 --- a/backend/Application/obj/Debug/net8.0/Application.AssemblyInfoInputs.cache +++ b/backend/Application/obj/Debug/net8.0/Application.AssemblyInfoInputs.cache @@ -1 +1 @@ -0cb94e40182d1b6cd5700fb1c27327d72d0012508a1d486af3eaad106de53053 +5ebc7e7564dc4079f778b09cac511dae388a84af6e87589df0498d0a9bc6364f diff --git a/backend/Application/obj/Debug/net8.0/Application.csproj.AssemblyReference.cache b/backend/Application/obj/Debug/net8.0/Application.csproj.AssemblyReference.cache index c09508f..0467b12 100644 Binary files a/backend/Application/obj/Debug/net8.0/Application.csproj.AssemblyReference.cache and b/backend/Application/obj/Debug/net8.0/Application.csproj.AssemblyReference.cache differ diff --git a/backend/Application/obj/Debug/net8.0/Application.csproj.CoreCompileInputs.cache b/backend/Application/obj/Debug/net8.0/Application.csproj.CoreCompileInputs.cache index 2041c72..ff2c948 100644 --- a/backend/Application/obj/Debug/net8.0/Application.csproj.CoreCompileInputs.cache +++ b/backend/Application/obj/Debug/net8.0/Application.csproj.CoreCompileInputs.cache @@ -1 +1 @@ -d60e6c6b63d7c5372a4c397784287b9f857dcb3972545a2d619ebddba564fc35 +26e7a7899234aa69b1e72639220f61d98aa121dd4eb93d18c3595c34f36f0d99 diff --git a/backend/Application/obj/Debug/net8.0/Application.dll b/backend/Application/obj/Debug/net8.0/Application.dll index f11d862..d5f2864 100644 Binary files a/backend/Application/obj/Debug/net8.0/Application.dll and b/backend/Application/obj/Debug/net8.0/Application.dll differ diff --git a/backend/Application/obj/Debug/net8.0/Application.pdb b/backend/Application/obj/Debug/net8.0/Application.pdb index 719663b..598c982 100644 Binary files a/backend/Application/obj/Debug/net8.0/Application.pdb and b/backend/Application/obj/Debug/net8.0/Application.pdb differ diff --git a/backend/Application/obj/Debug/net8.0/Application.sourcelink.json b/backend/Application/obj/Debug/net8.0/Application.sourcelink.json index 27ac5fa..6807585 100644 --- a/backend/Application/obj/Debug/net8.0/Application.sourcelink.json +++ b/backend/Application/obj/Debug/net8.0/Application.sourcelink.json @@ -1 +1 @@ -{"documents":{"C:\\Users\\Andrei Cerbu\\Documents\\FACULTATE\\CC-FinalProj\\*":"https://raw.githubusercontent.com/andrei-mihnea-cerbu/CC-FinalProj/015a1a9c09fe601a8c8b9f61de5c7d87b5a73607/*"}} \ No newline at end of file +{"documents":{"C:\\Users\\Andrei Cerbu\\Documents\\FACULTATE\\CC-FinalProj\\*":"https://raw.githubusercontent.com/andrei-mihnea-cerbu/CC-FinalProj/0d03c0ea4308c032d708d3ee63f648b10811c65f/*"}} \ No newline at end of file diff --git a/backend/Application/obj/Debug/net8.0/ref/Application.dll b/backend/Application/obj/Debug/net8.0/ref/Application.dll index 617d90a..82f13ad 100644 Binary files a/backend/Application/obj/Debug/net8.0/ref/Application.dll and b/backend/Application/obj/Debug/net8.0/ref/Application.dll differ diff --git a/backend/Application/obj/Debug/net8.0/refint/Application.dll b/backend/Application/obj/Debug/net8.0/refint/Application.dll index 617d90a..82f13ad 100644 Binary files a/backend/Application/obj/Debug/net8.0/refint/Application.dll and b/backend/Application/obj/Debug/net8.0/refint/Application.dll differ diff --git a/backend/Core/bin/Debug/net8.0/Core.dll b/backend/Core/bin/Debug/net8.0/Core.dll index 8225300..2d5ca28 100644 Binary files a/backend/Core/bin/Debug/net8.0/Core.dll and b/backend/Core/bin/Debug/net8.0/Core.dll differ diff --git a/backend/Core/bin/Debug/net8.0/Core.pdb b/backend/Core/bin/Debug/net8.0/Core.pdb index 06c7fc0..07208af 100644 Binary files a/backend/Core/bin/Debug/net8.0/Core.pdb and b/backend/Core/bin/Debug/net8.0/Core.pdb differ diff --git a/backend/Core/obj/Debug/net8.0/Core.AssemblyInfo.cs b/backend/Core/obj/Debug/net8.0/Core.AssemblyInfo.cs index ef0ef75..1935a96 100644 --- a/backend/Core/obj/Debug/net8.0/Core.AssemblyInfo.cs +++ b/backend/Core/obj/Debug/net8.0/Core.AssemblyInfo.cs @@ -13,7 +13,7 @@ using System.Reflection; [assembly: System.Reflection.AssemblyCompanyAttribute("Core")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] -[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+015a1a9c09fe601a8c8b9f61de5c7d87b5a73607")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+0d03c0ea4308c032d708d3ee63f648b10811c65f")] [assembly: System.Reflection.AssemblyProductAttribute("Core")] [assembly: System.Reflection.AssemblyTitleAttribute("Core")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] diff --git a/backend/Core/obj/Debug/net8.0/Core.AssemblyInfoInputs.cache b/backend/Core/obj/Debug/net8.0/Core.AssemblyInfoInputs.cache index d266afa..9989e26 100644 --- a/backend/Core/obj/Debug/net8.0/Core.AssemblyInfoInputs.cache +++ b/backend/Core/obj/Debug/net8.0/Core.AssemblyInfoInputs.cache @@ -1 +1 @@ -67e59afccb449e467919aa45b8e4747b643eec04fa68b13d647704ff737ee4fc +5a6e74a12f0945636560f529431fe24f2f54ca0d381dda4f2ec4349776fcc2bd diff --git a/backend/Core/obj/Debug/net8.0/Core.dll b/backend/Core/obj/Debug/net8.0/Core.dll index 8225300..2d5ca28 100644 Binary files a/backend/Core/obj/Debug/net8.0/Core.dll and b/backend/Core/obj/Debug/net8.0/Core.dll differ diff --git a/backend/Core/obj/Debug/net8.0/Core.pdb b/backend/Core/obj/Debug/net8.0/Core.pdb index 06c7fc0..07208af 100644 Binary files a/backend/Core/obj/Debug/net8.0/Core.pdb and b/backend/Core/obj/Debug/net8.0/Core.pdb differ diff --git a/backend/Core/obj/Debug/net8.0/Core.sourcelink.json b/backend/Core/obj/Debug/net8.0/Core.sourcelink.json index 27ac5fa..6807585 100644 --- a/backend/Core/obj/Debug/net8.0/Core.sourcelink.json +++ b/backend/Core/obj/Debug/net8.0/Core.sourcelink.json @@ -1 +1 @@ -{"documents":{"C:\\Users\\Andrei Cerbu\\Documents\\FACULTATE\\CC-FinalProj\\*":"https://raw.githubusercontent.com/andrei-mihnea-cerbu/CC-FinalProj/015a1a9c09fe601a8c8b9f61de5c7d87b5a73607/*"}} \ No newline at end of file +{"documents":{"C:\\Users\\Andrei Cerbu\\Documents\\FACULTATE\\CC-FinalProj\\*":"https://raw.githubusercontent.com/andrei-mihnea-cerbu/CC-FinalProj/0d03c0ea4308c032d708d3ee63f648b10811c65f/*"}} \ No newline at end of file diff --git a/backend/Core/obj/Debug/net8.0/ref/Core.dll b/backend/Core/obj/Debug/net8.0/ref/Core.dll index 7e2b766..3153183 100644 Binary files a/backend/Core/obj/Debug/net8.0/ref/Core.dll and b/backend/Core/obj/Debug/net8.0/ref/Core.dll differ diff --git a/backend/Core/obj/Debug/net8.0/refint/Core.dll b/backend/Core/obj/Debug/net8.0/refint/Core.dll index 7e2b766..3153183 100644 Binary files a/backend/Core/obj/Debug/net8.0/refint/Core.dll and b/backend/Core/obj/Debug/net8.0/refint/Core.dll differ diff --git a/backend/Infrastructure/InfrastructureDI.cs b/backend/Infrastructure/InfrastructureDI.cs index 15cdb0c..fc849ee 100644 --- a/backend/Infrastructure/InfrastructureDI.cs +++ b/backend/Infrastructure/InfrastructureDI.cs @@ -1,8 +1,10 @@ using Application.Services.Database.MongoDB; using Application.Services.Database.PostgreSQL; +using Application.Services.Email; using Application.Services.HashingAlgorithms; using Application.Services.Jwt; using Infrastructure.Data; +using Infrastructure.Services.Email; using Infrastructure.Services.HashingAlgorithms; using Infrastructure.Services.MongoDB; using Infrastructure.Services.PostgreSQL; @@ -65,7 +67,8 @@ public static class DependencyInjection return new JwtService(configuration); }); - // services.AddScoped(); + services.Configure(configuration.GetSection("SmtpSettings")); + services.AddScoped(); return services; } diff --git a/backend/Infrastructure/Services/Email/EmailService.cs b/backend/Infrastructure/Services/Email/EmailService.cs new file mode 100644 index 0000000..6417f5a --- /dev/null +++ b/backend/Infrastructure/Services/Email/EmailService.cs @@ -0,0 +1,58 @@ +using Application.Services.Email; + +namespace Infrastructure.Services.Email; + +using System.Net; +using System.Net.Mail; +using System.Threading.Tasks; +using Microsoft.Extensions.Options; + +public class EmailService : IEmailService +{ + private readonly SmtpSettings _smtpSettings; + + public EmailService(IOptions smtpSettings) + { + _smtpSettings = smtpSettings.Value; + } + + public async Task SendEmailAsync(string to, string subject, string body) + { + Console.WriteLine(_smtpSettings.Host); + Console.WriteLine(_smtpSettings.Port); + + using (var client = new SmtpClient(_smtpSettings.Host, _smtpSettings.Port)) + { + client.EnableSsl = _smtpSettings.EnableSSL; + client.Credentials = new NetworkCredential(_smtpSettings.UserName, _smtpSettings.Password); + + var mailMessage = new MailMessage + { + From = new MailAddress(_smtpSettings.From), + Subject = subject, + Body = body, + IsBodyHtml = true + }; + mailMessage.To.Add(to); + + await client.SendMailAsync(mailMessage); + } + } + + public string GenerateCredentialsEmailBody(string email, string password) + { + string template = @" + + +

Welcome to HealthcareManager

+

You can now log in using the following credentials:

+

Email: {email}

+

Password: {password}

+

For security reasons, please change your password after logging in.

+ + "; + + return template.Replace("{email}", email).Replace("{password}", password); + } + +} diff --git a/backend/Infrastructure/SmptSettings.cs b/backend/Infrastructure/SmptSettings.cs new file mode 100644 index 0000000..4f67f29 --- /dev/null +++ b/backend/Infrastructure/SmptSettings.cs @@ -0,0 +1,11 @@ +namespace Infrastructure; + +public class SmtpSettings +{ + public string Host { get; set; } + public int Port { get; set; } + public string From { get; set; } + public bool EnableSSL { get; set; } + public string UserName { get; set; } + public string Password { get; set; } +} diff --git a/backend/Infrastructure/bin/Debug/net8.0/Application.dll b/backend/Infrastructure/bin/Debug/net8.0/Application.dll index f11d862..d5f2864 100644 Binary files a/backend/Infrastructure/bin/Debug/net8.0/Application.dll and b/backend/Infrastructure/bin/Debug/net8.0/Application.dll differ diff --git a/backend/Infrastructure/bin/Debug/net8.0/Application.pdb b/backend/Infrastructure/bin/Debug/net8.0/Application.pdb index 719663b..598c982 100644 Binary files a/backend/Infrastructure/bin/Debug/net8.0/Application.pdb and b/backend/Infrastructure/bin/Debug/net8.0/Application.pdb differ diff --git a/backend/Infrastructure/bin/Debug/net8.0/Core.dll b/backend/Infrastructure/bin/Debug/net8.0/Core.dll index 8225300..2d5ca28 100644 Binary files a/backend/Infrastructure/bin/Debug/net8.0/Core.dll and b/backend/Infrastructure/bin/Debug/net8.0/Core.dll differ diff --git a/backend/Infrastructure/bin/Debug/net8.0/Core.pdb b/backend/Infrastructure/bin/Debug/net8.0/Core.pdb index 06c7fc0..07208af 100644 Binary files a/backend/Infrastructure/bin/Debug/net8.0/Core.pdb and b/backend/Infrastructure/bin/Debug/net8.0/Core.pdb differ diff --git a/backend/Infrastructure/bin/Debug/net8.0/Infrastructure.dll b/backend/Infrastructure/bin/Debug/net8.0/Infrastructure.dll index 6a14d5d..415c18b 100644 Binary files a/backend/Infrastructure/bin/Debug/net8.0/Infrastructure.dll and b/backend/Infrastructure/bin/Debug/net8.0/Infrastructure.dll differ diff --git a/backend/Infrastructure/bin/Debug/net8.0/Infrastructure.pdb b/backend/Infrastructure/bin/Debug/net8.0/Infrastructure.pdb index ffcc07d..394efdf 100644 Binary files a/backend/Infrastructure/bin/Debug/net8.0/Infrastructure.pdb and b/backend/Infrastructure/bin/Debug/net8.0/Infrastructure.pdb differ diff --git a/backend/Infrastructure/obj/Debug/net8.0/Infrastructure.AssemblyInfo.cs b/backend/Infrastructure/obj/Debug/net8.0/Infrastructure.AssemblyInfo.cs index f6a1372..e229f48 100644 --- a/backend/Infrastructure/obj/Debug/net8.0/Infrastructure.AssemblyInfo.cs +++ b/backend/Infrastructure/obj/Debug/net8.0/Infrastructure.AssemblyInfo.cs @@ -13,7 +13,7 @@ using System.Reflection; [assembly: System.Reflection.AssemblyCompanyAttribute("Infrastructure")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] -[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+015a1a9c09fe601a8c8b9f61de5c7d87b5a73607")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+0d03c0ea4308c032d708d3ee63f648b10811c65f")] [assembly: System.Reflection.AssemblyProductAttribute("Infrastructure")] [assembly: System.Reflection.AssemblyTitleAttribute("Infrastructure")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] diff --git a/backend/Infrastructure/obj/Debug/net8.0/Infrastructure.AssemblyInfoInputs.cache b/backend/Infrastructure/obj/Debug/net8.0/Infrastructure.AssemblyInfoInputs.cache index f8df6a9..9275678 100644 --- a/backend/Infrastructure/obj/Debug/net8.0/Infrastructure.AssemblyInfoInputs.cache +++ b/backend/Infrastructure/obj/Debug/net8.0/Infrastructure.AssemblyInfoInputs.cache @@ -1 +1 @@ -2df5e0f93be8613fe06b8383df37707a7c1dcd41012222f47d70221d4c2a316f +216a0769924e0848d0c09eb46e477765dd2a8d7e28503106a43024c1a9d666a1 diff --git a/backend/Infrastructure/obj/Debug/net8.0/Infrastructure.csproj.AssemblyReference.cache b/backend/Infrastructure/obj/Debug/net8.0/Infrastructure.csproj.AssemblyReference.cache index 2d9f63e..5f95476 100644 Binary files a/backend/Infrastructure/obj/Debug/net8.0/Infrastructure.csproj.AssemblyReference.cache and b/backend/Infrastructure/obj/Debug/net8.0/Infrastructure.csproj.AssemblyReference.cache differ diff --git a/backend/Infrastructure/obj/Debug/net8.0/Infrastructure.csproj.CoreCompileInputs.cache b/backend/Infrastructure/obj/Debug/net8.0/Infrastructure.csproj.CoreCompileInputs.cache index 0471bdc..2c0b44e 100644 --- a/backend/Infrastructure/obj/Debug/net8.0/Infrastructure.csproj.CoreCompileInputs.cache +++ b/backend/Infrastructure/obj/Debug/net8.0/Infrastructure.csproj.CoreCompileInputs.cache @@ -1 +1 @@ -f7db5be1a68464cc50c7ccee2ec8ca8c6b9870991fcbe7daa2045fdfe78ab58e +36246167bc67f799ef7d06b38addbdbc2934572b797d99ee0e80ef15f6df67cd diff --git a/backend/Infrastructure/obj/Debug/net8.0/Infrastructure.dll b/backend/Infrastructure/obj/Debug/net8.0/Infrastructure.dll index 6a14d5d..415c18b 100644 Binary files a/backend/Infrastructure/obj/Debug/net8.0/Infrastructure.dll and b/backend/Infrastructure/obj/Debug/net8.0/Infrastructure.dll differ diff --git a/backend/Infrastructure/obj/Debug/net8.0/Infrastructure.pdb b/backend/Infrastructure/obj/Debug/net8.0/Infrastructure.pdb index ffcc07d..394efdf 100644 Binary files a/backend/Infrastructure/obj/Debug/net8.0/Infrastructure.pdb and b/backend/Infrastructure/obj/Debug/net8.0/Infrastructure.pdb differ diff --git a/backend/Infrastructure/obj/Debug/net8.0/Infrastructure.sourcelink.json b/backend/Infrastructure/obj/Debug/net8.0/Infrastructure.sourcelink.json index 27ac5fa..6807585 100644 --- a/backend/Infrastructure/obj/Debug/net8.0/Infrastructure.sourcelink.json +++ b/backend/Infrastructure/obj/Debug/net8.0/Infrastructure.sourcelink.json @@ -1 +1 @@ -{"documents":{"C:\\Users\\Andrei Cerbu\\Documents\\FACULTATE\\CC-FinalProj\\*":"https://raw.githubusercontent.com/andrei-mihnea-cerbu/CC-FinalProj/015a1a9c09fe601a8c8b9f61de5c7d87b5a73607/*"}} \ No newline at end of file +{"documents":{"C:\\Users\\Andrei Cerbu\\Documents\\FACULTATE\\CC-FinalProj\\*":"https://raw.githubusercontent.com/andrei-mihnea-cerbu/CC-FinalProj/0d03c0ea4308c032d708d3ee63f648b10811c65f/*"}} \ No newline at end of file diff --git a/backend/Infrastructure/obj/Debug/net8.0/ref/Infrastructure.dll b/backend/Infrastructure/obj/Debug/net8.0/ref/Infrastructure.dll index ec04aae..e9e09db 100644 Binary files a/backend/Infrastructure/obj/Debug/net8.0/ref/Infrastructure.dll and b/backend/Infrastructure/obj/Debug/net8.0/ref/Infrastructure.dll differ diff --git a/backend/Infrastructure/obj/Debug/net8.0/refint/Infrastructure.dll b/backend/Infrastructure/obj/Debug/net8.0/refint/Infrastructure.dll index ec04aae..e9e09db 100644 Binary files a/backend/Infrastructure/obj/Debug/net8.0/refint/Infrastructure.dll and b/backend/Infrastructure/obj/Debug/net8.0/refint/Infrastructure.dll differ