diff --git a/libs/auth-domain/src/lib/services/auth.service.ts b/libs/auth-domain/src/lib/services/auth.service.ts index 6b4d48b5..61fe1d1a 100644 --- a/libs/auth-domain/src/lib/services/auth.service.ts +++ b/libs/auth-domain/src/lib/services/auth.service.ts @@ -7,6 +7,7 @@ import { AuthErrorCodes, UserErrorCodes, } from '@toxictoast/azkaban-base-helpers'; +import { Logger } from '@nestjs/common'; export class AuthService { private readonly factory: AuthFactory = new AuthFactory(); @@ -25,6 +26,7 @@ export class AuthService { async findByEmail(email: string): Promise> { try { const result = await this.repository.findByEmail(email); + Logger.debug({ result }, 'findByEmail'); return Result.ok(result); } catch (error) { return Result.fail(error); @@ -34,6 +36,7 @@ export class AuthService { async findByUsername(username: string): Promise> { try { const result = await this.repository.findByUsername(username); + Logger.debug({ result }, 'findByUsername'); return Result.ok(result); } catch (error) { return Result.fail(error); @@ -52,11 +55,11 @@ export class AuthService { async createUser(data: AuthData): Promise> { try { const checkEmail = await this.findByEmail(data.email); - if (checkEmail.isSuccess) { + if (checkEmail.value !== null) { return Result.fail(AuthErrorCodes.EMAIL_FOUND); } const checkUsername = await this.findByUsername(data.username); - if (checkUsername.isSuccess) { + if (checkUsername.value !== null) { return Result.fail(AuthErrorCodes.USERNAME_FOUND); } const aggregate = this.factory.createDomain(data);