From 7eb81039aaa53b1348d9b2b9aac36a502f3f7346 Mon Sep 17 00:00:00 2001 From: Aaron Po Date: Sun, 15 Feb 2026 11:26:55 -0500 Subject: [PATCH] remove email out of register service --- .../Service/Service.Auth/RegisterService.cs | 29 ++++--------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/src/Core/Service/Service.Auth/RegisterService.cs b/src/Core/Service/Service.Auth/RegisterService.cs index 3554005..03bb988 100644 --- a/src/Core/Service/Service.Auth/RegisterService.cs +++ b/src/Core/Service/Service.Auth/RegisterService.cs @@ -9,12 +9,10 @@ namespace Service.Auth; public class RegisterService( IAuthRepository authRepo, - IPasswordInfrastructure passwordInfrastructure, - IEmailProvider emailProvider, - IEmailTemplateProvider emailTemplateProvider + IPasswordInfrastructure passwordInfrastructure ) : IRegisterService { - public async Task RegisterAsync(UserAccount userAccount, string password) + private async Task ValidateUserDoesNotExist(UserAccount userAccount) { // Check if user already exists var existingUsername = await authRepo.GetUserByUsernameAsync(userAccount.Username); @@ -24,8 +22,11 @@ public class RegisterService( { throw new ConflictException("Username or email already exists"); } + } - + public async Task RegisterAsync(UserAccount userAccount, string password) + { + await ValidateUserDoesNotExist(userAccount); // password hashing var hashed = passwordInfrastructure.Hash(password); @@ -38,24 +39,6 @@ public class RegisterService( userAccount.DateOfBirth, hashed); - - // Generate confirmation link (TODO: implement proper token-based confirmation) - var confirmationLink = $"https://thebiergarten.app/confirm?email={Uri.EscapeDataString(createdUser.Email)}"; - - // Render email template - var emailHtml = await emailTemplateProvider.RenderUserRegisteredEmailAsync( - createdUser.FirstName, - confirmationLink - ); - - // Send welcome email with rendered template - await emailProvider.SendAsync( - createdUser.Email, - "Welcome to The Biergarten App!", - emailHtml, - isHtml: true - ); - return createdUser; } }