From 20f2a251b61e8b4edf7489dad090b1113229c574 Mon Sep 17 00:00:00 2001 From: Antoine Moreaux Date: Tue, 25 Mar 2025 18:58:53 +0100 Subject: [PATCH] fix(auth): handle missing workspaceId in auth service (#11173) Add a check to return undefined if workspaceId is not provided. Prevents unnecessary execution and potential errors during workspace lookup. --- .../core-modules/auth/services/auth.service.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/twenty-server/src/engine/core-modules/auth/services/auth.service.ts b/packages/twenty-server/src/engine/core-modules/auth/services/auth.service.ts index af12da975..db03c32b1 100644 --- a/packages/twenty-server/src/engine/core-modules/auth/services/auth.service.ts +++ b/packages/twenty-server/src/engine/core-modules/auth/services/auth.service.ts @@ -562,12 +562,14 @@ export class AuthService { ); } - return await this.workspaceRepository.findOne({ - where: { - id: params.workspaceId, - }, - relations: ['approvedAccessDomains'], - }); + return params.workspaceId + ? await this.workspaceRepository.findOne({ + where: { + id: params.workspaceId, + }, + relations: ['approvedAccessDomains'], + }) + : undefined; } formatUserDataPayload(