From ef27d6f5531ebd72f92c510f9f4da04deb1a0891 Mon Sep 17 00:00:00 2001 From: Aaron Po Date: Fri, 6 Mar 2026 23:13:01 -0500 Subject: [PATCH] Create ConfirmationService class file and extract out of interface file --- .../Service.Auth/ConfirmationService.cs | 34 +++++++++++++++++++ .../Service.Auth/IConfirmationService.cs | 24 ------------- 2 files changed, 34 insertions(+), 24 deletions(-) create mode 100644 src/Core/Service/Service.Auth/ConfirmationService.cs diff --git a/src/Core/Service/Service.Auth/ConfirmationService.cs b/src/Core/Service/Service.Auth/ConfirmationService.cs new file mode 100644 index 0000000..ff4abf0 --- /dev/null +++ b/src/Core/Service/Service.Auth/ConfirmationService.cs @@ -0,0 +1,34 @@ + +using Domain.Exceptions; +using Infrastructure.Repository.Auth; + +namespace Service.Auth; + +public class ConfirmationService( + IAuthRepository authRepository, + ITokenService tokenService +) : IConfirmationService +{ + public async Task ConfirmUserAsync( + string confirmationToken + ) + { + var validatedToken = await tokenService.ValidateConfirmationTokenAsync( + confirmationToken + ); + + var user = await authRepository.ConfirmUserAccountAsync( + validatedToken.UserId + ); + + if (user == null) + { + throw new UnauthorizedException("User account not found"); + } + + return new ConfirmationServiceReturn( + DateTime.UtcNow, + user.UserAccountId + ); + } +} diff --git a/src/Core/Service/Service.Auth/IConfirmationService.cs b/src/Core/Service/Service.Auth/IConfirmationService.cs index ec5e2cf..8abb9be 100644 --- a/src/Core/Service/Service.Auth/IConfirmationService.cs +++ b/src/Core/Service/Service.Auth/IConfirmationService.cs @@ -9,27 +9,3 @@ public interface IConfirmationService { Task ConfirmUserAsync(string confirmationToken); } - -public class ConfirmationService(IAuthRepository authRepository, ITokenService tokenService) - : IConfirmationService -{ - public async Task ConfirmUserAsync( - string confirmationToken - ) - { - var validatedToken = await tokenService.ValidateConfirmationTokenAsync( - confirmationToken - ); - - var user = await authRepository.ConfirmUserAccountAsync( - validatedToken.UserId - ); - - if (user == null) - { - throw new UnauthorizedException("User account not found"); - } - - return new ConfirmationServiceReturn(DateTime.UtcNow, user.UserAccountId); - } -}