Skip to content

The open alternative to Salesforce, designed for AI.

fix(auth, workspace-invitation): enforce required subdomains (#9464)

Antoine Moreauxd61409a5dfe9
diff --git a/packages/twenty-server/src/engine/core-modules/auth/services/sign-in-up.service.spec.ts b/packages/twenty-server/src/engine/core-modules/auth/services/sign-in-up.service.spec.ts
index df14306f755..3c69476244b 100644
--- a/packages/twenty-server/src/engine/core-modules/auth/services/sign-in-up.service.spec.ts
+++ b/packages/twenty-server/src/engine/core-modules/auth/services/sign-in-up.service.spec.ts
@@ -498,6 +498,7 @@ describe('SignInUpService', () => {
email,
password,
fromSSO: false,
+ targetWorkspaceSubdomain: 'testSubDomain',
workspaceInviteHash,
});
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 53a8028cb80..c5ffa46039b 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
@@ -122,19 +122,21 @@ export class SignInUpService {
}
}
- const signInUpWithInvitationResult = await this.signInUpWithInvitation({
- email,
- workspacePersonalInviteToken,
- workspaceInviteHash,
- targetWorkspaceSubdomain,
- fromSSO,
- firstName,
- lastName,
- picture,
- authProvider,
- passwordHash,
- existingUser,
- });
+ const signInUpWithInvitationResult = targetWorkspaceSubdomain
+ ? await this.signInUpWithInvitation({
+ email,
+ workspacePersonalInviteToken,
+ workspaceInviteHash,
+ targetWorkspaceSubdomain,
+ fromSSO,
+ firstName,
+ lastName,
+ picture,
+ authProvider,
+ passwordHash,
+ existingUser,
+ })
+ : undefined;
if (isDefined(signInUpWithInvitationResult)) {
return signInUpWithInvitationResult;
@@ -187,7 +189,7 @@ export class SignInUpService {
passwordHash?: string;
existingUser: User | null;
fromSSO: boolean;
- targetWorkspaceSubdomain?: string;
+ targetWorkspaceSubdomain: string;
}) {
const maybeInvitation =
fromSSO && !workspacePersonalInviteToken && !workspaceInviteHash
diff --git a/packages/twenty-server/src/engine/core-modules/workspace-invitation/services/workspace-invitation.service.ts b/packages/twenty-server/src/engine/core-modules/workspace-invitation/services/workspace-invitation.service.ts
index ce95f3da28c..8d4594ab979 100644
--- a/packages/twenty-server/src/engine/core-modules/workspace-invitation/services/workspace-invitation.service.ts
+++ b/packages/twenty-server/src/engine/core-modules/workspace-invitation/services/workspace-invitation.service.ts
@@ -139,7 +139,7 @@ export class WorkspaceInvitationService {
subdomain,
email,
}: {
- subdomain?: string;
+ subdomain: string;
email: string;
}) {
const workspace =