From 83434deb22937e019f4a7b3f73c52cd18de99213 Mon Sep 17 00:00:00 2001 From: Antoine Moreaux Date: Sat, 19 Apr 2025 15:28:41 +0200 Subject: [PATCH] refactor(auth): optimize work email handling in sign-up flow (#11655) Extracted isWorkEmail check into a variable for reusability and adjusted subdomain generation to conditionally include email. This enhances code readability and maintains logic consistency. --- .../core-modules/auth/services/sign-in-up.service.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/twenty-server/src/engine/core-modules/auth/services/sign-in-up.service.ts b/packages/twenty-server/src/engine/core-modules/auth/services/sign-in-up.service.ts index beb6715b3..5c63f1df7 100644 --- a/packages/twenty-server/src/engine/core-modules/auth/services/sign-in-up.service.ts +++ b/packages/twenty-server/src/engine/core-modules/auth/services/sign-in-up.service.ts @@ -352,11 +352,14 @@ export class SignInUpService { } }; + const isWorkEmailFound = isWorkEmail(email); const logo = - isWorkEmail(email) && (await isLogoUrlValid()) ? logoUrl : undefined; + isWorkEmailFound && (await isLogoUrlValid()) ? logoUrl : undefined; const workspaceToCreate = this.workspaceRepository.create({ - subdomain: await this.domainManagerService.generateSubdomain(), + subdomain: await this.domainManagerService.generateSubdomain( + isWorkEmailFound ? { email } : {}, + ), displayName: '', inviteHash: v4(), activationStatus: WorkspaceActivationStatus.PENDING_CREATION,