Skip to content

Commit 34d9fca

Browse files
authored
chore(auth): drop unused workspacePersonalInviteToken from SSO state (twentyhq#20557)
## Summary Pure dead-code removal. The Google and Microsoft SSO strategies have been packing `workspacePersonalInviteToken` into the OAuth `state` blob and re-emitting it on `validate()`, but [`signInUpWithSocialSSO`](packages/twenty-server/src/engine/core-modules/auth/services/auth.service.ts) never destructures or reads it from the user object. The SSO flow resolves invitations by the IdP-verified email instead: ```ts const invitation = currentWorkspace && email ? await this.findInvitationForSignInUp({ currentWorkspace, email, // ← matched against appToken.context.email }) : undefined; ``` So the strategy plumbing is write-only and confusing for readers. Removed from: - [`SocialSSOState`](packages/twenty-server/src/engine/core-modules/auth/types/social-sso-state.type.ts) - `GoogleRequest['user']` and `MicrosoftRequest['user']` - The `state` JSON in both strategies' `authenticate()` - The user object in both strategies' `validate()` No frontend change needed — `useAuth.buildRedirectUrl` still sets the `inviteToken` query param when a personal invite token is present (used by other paths), and nothing on the SSO server side was reading it. The token-based invitation lookup is preserved for the password signup flow via `auth.resolver.signUp` → `findInvitationForSignInUp({ currentWorkspace, workspacePersonalInviteToken })`. Unrelated, untouched. ## Test plan - [x] `npx jest engine/core-modules/auth` (twenty-server) — 26 suites / 178 tests pass. - [x] `tsgo -p tsconfig.json --noEmit` — no new errors on the touched files (pre-existing `IS_REST_METADATA_API_NEW_FORMAT_DIRECT` errors on main are unrelated). - [x] `oxlint` + `prettier --check` on touched files — clean. - [ ] Manual smoke: Google sign-in still works (workspace selection / verify flow unaffected since `workspaceInviteHash`, `workspaceId`, `action`, `locale`, `billingCheckoutSessionState`, `returnToPath` still flow correctly).
1 parent 8edc76d commit 34d9fca

3 files changed

Lines changed: 0 additions & 7 deletions

File tree

packages/twenty-server/src/engine/core-modules/auth/strategies/google.auth.strategy.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ export type GoogleRequest = Omit<
2929
picture: string | null;
3030
locale?: keyof typeof APP_LOCALES | null;
3131
workspaceInviteHash?: string;
32-
workspacePersonalInviteToken?: string;
3332
action: SocialSSOSignInUpActionType;
3433
workspaceId?: string;
3534
billingCheckoutSessionState?: string;
@@ -57,7 +56,6 @@ export class GoogleStrategy extends PassportStrategy(Strategy, 'google') {
5756
workspaceInviteHash: req.query.workspaceInviteHash,
5857
workspaceId: req.params.workspaceId,
5958
billingCheckoutSessionState: req.query.billingCheckoutSessionState,
60-
workspacePersonalInviteToken: req.query.workspacePersonalInviteToken,
6159
action: req.query.action,
6260
locale: req.query.locale,
6361
returnToPath: req.query.returnToPath,
@@ -94,7 +92,6 @@ export class GoogleStrategy extends PassportStrategy(Strategy, 'google') {
9492
lastName: name?.familyName,
9593
picture: photos?.[0]?.value ?? null,
9694
workspaceInviteHash: state?.workspaceInviteHash,
97-
workspacePersonalInviteToken: state?.workspacePersonalInviteToken,
9895
workspaceId: state?.workspaceId,
9996
billingCheckoutSessionState: state?.billingCheckoutSessionState,
10097
action: state?.action ?? 'list-available-workspaces',

packages/twenty-server/src/engine/core-modules/auth/strategies/microsoft.auth.strategy.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ export type MicrosoftRequest = Omit<
2727
picture: string | null;
2828
locale?: keyof typeof APP_LOCALES | null;
2929
workspaceInviteHash?: string;
30-
workspacePersonalInviteToken?: string;
3130
workspaceId?: string;
3231
billingCheckoutSessionState?: string;
3332
action: SocialSSOSignInUpActionType;
@@ -57,7 +56,6 @@ export class MicrosoftStrategy extends PassportStrategy(Strategy, 'microsoft') {
5756
workspaceId: req.params.workspaceId,
5857
locale: req.query.locale,
5958
billingCheckoutSessionState: req.query.billingCheckoutSessionState,
60-
workspacePersonalInviteToken: req.query.workspacePersonalInviteToken,
6159
action: req.query.action,
6260
returnToPath: req.query.returnToPath,
6361
oauthRetryCount: req.query.oauthRetryCount
@@ -92,7 +90,6 @@ export class MicrosoftStrategy extends PassportStrategy(Strategy, 'microsoft') {
9290
lastName: name?.familyName,
9391
picture: photos?.[0]?.value ?? null,
9492
workspaceInviteHash: state?.workspaceInviteHash,
95-
workspacePersonalInviteToken: state?.workspacePersonalInviteToken,
9693
workspaceId: state?.workspaceId,
9794
billingCheckoutSessionState: state?.billingCheckoutSessionState,
9895
locale: state?.locale,

packages/twenty-server/src/engine/core-modules/auth/types/social-sso-state.type.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ export type SocialSSOState = {
66
workspaceInviteHash?: string;
77
workspaceId?: string;
88
billingCheckoutSessionState?: string;
9-
workspacePersonalInviteToken?: string;
109
action?: SocialSSOSignInUpActionType;
1110
locale?: keyof typeof APP_LOCALES;
1211
returnToPath?: string;

0 commit comments

Comments
 (0)