The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
fix(auth): improve query to find invitation (#9743)
Antoine Moreaux4254ce9b2b1c
diff --git a/packages/twenty-server/src/engine/core-modules/auth/controllers/google-auth.controller.ts b/packages/twenty-server/src/engine/core-modules/auth/controllers/google-auth.controller.tsindex 644f857ab8f..7a4b9ba4fe1 100644--- a/packages/twenty-server/src/engine/core-modules/auth/controllers/google-auth.controller.ts+++ b/packages/twenty-server/src/engine/core-modules/auth/controllers/google-auth.controller.ts@@ -70,7 +70,6 @@ export class GoogleAuthController {currentWorkspace && workspacePersonalInviteToken && email? await this.authService.findInvitationForSignInUp({currentWorkspace,- workspacePersonalInviteToken,email,}): undefined;diff --git a/packages/twenty-server/src/engine/core-modules/auth/controllers/microsoft-auth.controller.ts b/packages/twenty-server/src/engine/core-modules/auth/controllers/microsoft-auth.controller.tsindex 5e5a4e7086a..90c1295402b 100644--- a/packages/twenty-server/src/engine/core-modules/auth/controllers/microsoft-auth.controller.ts+++ b/packages/twenty-server/src/engine/core-modules/auth/controllers/microsoft-auth.controller.ts@@ -68,7 +68,6 @@ export class MicrosoftAuthController {currentWorkspace && workspacePersonalInviteToken && email? await this.authService.findInvitationForSignInUp({currentWorkspace,- workspacePersonalInviteToken,email,}): undefined;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.tsindex 252fc04a2ca..6d8bc98ecfe 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@@ -475,35 +475,29 @@ export class AuthService {return url.toString();}- async findInvitationForSignInUp({- currentWorkspace,- workspacePersonalInviteToken,- email,- }: {- currentWorkspace: Workspace | null;- workspacePersonalInviteToken?: string;- email?: string;- }) {- if (!currentWorkspace || !workspacePersonalInviteToken) return undefined;-+ async findInvitationForSignInUp(+ params: {+ currentWorkspace: Workspace;+ } & ({ workspacePersonalInviteToken: string } | { email: string }),+ ) {const qr = this.appTokenRepository.createQueryBuilder('appToken').where('"appToken"."workspaceId" = :workspaceId', {- workspaceId: currentWorkspace.id,+ workspaceId: params.currentWorkspace.id,}).andWhere('"appToken".type = :type', {type: AppTokenType.InvitationToken,});- if (workspacePersonalInviteToken) {+ if ('workspacePersonalInviteToken' in params) {qr.andWhere('"appToken".value = :personalInviteToken', {- personalInviteToken: workspacePersonalInviteToken,+ personalInviteToken: params.workspacePersonalInviteToken,});}- if (email) {+ if ('email' in params) {qr.andWhere('"appToken".context->>\'email\' = :email', {- email,+ email: params.email,});}