Skip to content

Offer organization creation in the self-host switcher to root owners - #84

Open
shuv1337 wants to merge 1 commit into
feat/selfhost-multi-org-isolationfrom
feat/selfhost-multi-org-ui
Open

shuv1337 wants to merge 1 commit into
feat/selfhost-multi-org-isolationfrom
feat/selfhost-multi-org-ui

Conversation

@shuv1337

@shuv1337 shuv1337 commented Nov 5, 2026

Copy link
Copy Markdown
Owner

Why

Self-host is getting real multi-organization support with owner-only creation. The dashboard's organization switcher should offer "Create organization" to exactly the people the server lets create, the root organization's owners, and switching should show each organization its own data. Stacked on #83. This is the top of the stack, so its selection below covers every layer.

What changed

  • GET /api/auth/self-host/capabilities (session only) returns { createOrganization } from the same ownsRoot check the create endpoint applies. Bearer callers and anonymous callers get 401.
  • organizationCreationAtom (browser only) reads it. The self-host org layout passes allowCreateOrganization as true only on a successful true, and it stays false while loading, after a failure and during server rendering. The action sits inside the closed switcher menu, so nothing shifts when it appears.
  • The entry page keeps allowCreate={false}: on self-host, someone with no organization cannot hold a session.

Verification

bun run check: exit 0.

self-host-organization-switcher.spec.ts (new), passed:

  • The owner's capabilities answer is true. The owner creates "Second team" from the switcher and lands on /org/second-team/apps, which lists none of the root's apps. Switching back shows the root's app.
  • The admin's answer is false. The admin's switcher lists one organization and no create action.

Negative check: forcing the action on makes the scenario fail on the admin ([1, 1] instead of [1, 0]).

Whole stack, run on this branch: 31/31 selected self-host scenarios passed. That covers every new or changed spec, the invitation, onboarding and password login scenarios, and the dashboard read-count and batch scenarios, which could see the new read. The fork CI security scenarios: 5/5 passed.

self-host-organization-switcher.spec.ts
self-host-organization-creation.spec.ts
self-host-many-organizations.spec.ts
self-host-sso.spec.ts
resource-isolation.spec.ts
groups.spec.ts
pat-mcp.spec.ts
dashboard-batch-isolation.spec.ts
invitation-redemption.spec.ts
invitation-roles.spec.ts
invitation-reaccept.spec.ts
invitation-security.spec.ts
invitation-dialog.spec.ts
self-host-onboarding.spec.ts
hosted.spec.ts
dashboard-request-volume.spec.ts
dashboard-read-batches.spec.ts
query-refresh.spec.ts

A signed-in user's GET /api/auth/self-host/capabilities answers whether they
may create organizations, from the same root-owner check the create endpoint
applies. The self-host switcher shows Create organization only when it says
so; the server still refuses everyone else.

Co-authored-by: Cursor <cursoragent@cursor.com>
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.

1 participant