Skip to content

feat(organizations): disable personal account for new users joining via invite - #4447

Merged
RSO merged 2 commits into
mainfrom
disable-personal-account-on-invite
Jul 8, 2026
Merged

feat(organizations): disable personal account for new users joining via invite#4447
RSO merged 2 commits into
mainfrom
disable-personal-account-on-invite

Conversation

@RSO

@RSO RSO commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Set personal_account_disabled = true for brand-new accounts that are created specifically to accept an organization invite, at the moment they join.
  • Existing users who accept an invite keep their current personal_account_disabled value.

Implementation

  • acceptOrganizationInvite gains an isNewUser parameter (default false). When a new membership is inserted and isNewUser is true, it updates the user's personal_account_disabled to true within the same transaction. The "already a member" path is unaffected.
  • The accept-invite page passes session.isNewUser, which is set at signup time and propagated through the JWT/session, so it is true exactly when the account was just created and false for existing users signing in.

Testing

  • pnpm --filter web typecheck
  • Added and ran tests in organizations.test.ts covering both the new-user (disabled) and existing-user (unchanged) paths.

RSO added 2 commits July 8, 2026 10:42
…ia invite

When a brand-new account is created specifically to accept an organization
invite, set personal_account_disabled to true on join. Existing users keep
their current value.
Replace the broad session-level isNewUser flag with a deterministic check:
disable the personal account only when the invitation predates the account,
i.e. the account was created because of an already-pending invite. This avoids
disabling personal accounts for users who signed up independently and are later
invited to an organization.
@RSO
RSO marked this pull request as ready for review July 8, 2026 08:56
@RSO
RSO merged commit 5e5fe98 into main Jul 8, 2026
15 checks passed
@RSO
RSO deleted the disable-personal-account-on-invite branch July 8, 2026 09:18
@kilo-code-bot

kilo-code-bot Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Executive Summary

Reviewed the invite-recency heuristic that disables a new user's personal account and found no correctness, security, or migration issues in the changed lines.

Files Reviewed (2 files)
  • apps/web/src/lib/organizations/organizations.ts
  • apps/web/src/lib/organizations/organizations.test.ts

Reviewed by claude-sonnet-5-20260630 · Input: 36 · Output: 15.3K · Cached: 1.1M

Review guidance: REVIEW.md from base branch main

RSO added a commit that referenced this pull request Jul 31, 2026
The invite flow (#4447) disables personal_account_disabled for accounts
created specifically to join an org, but the SSO JIT provisioning path
never did, so brand-new SSO signups kept the schema default of false.

Mirror the invite behavior in addSsoUserToOrganization: when a brand-new
account is provisioned via SSO and the membership is inserted, disable the
personal account within the same transaction. Existing users who
authenticate through SSO keep their current value.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants