Skip to content

tenancy: the cached default organization id is never revalidated, so after a deleted default organization is recreated new users are bound to the old id #21868

Description

@objectstack-fleet

Found by the independent review of PR #21813 (#21791). Low; predates 17.6.0, but #21813 makes it reachable (a recorded owner bind recreates a deleted default organization).

Mechanism

packages/plugins/plugin-auth/src/tenancy-service.ts (~L490) memoizes cachedDefaultOrgId for the life of the process. If the default organization is deleted and recreated in the same process, users created under the auto membership policy afterwards are bound to the deleted organization's id; since membership is now decided once at creation, nothing repairs it later.

Done when

The cached id is revalidated (or cleared on a sys_organization delete/insert), and a test deletes and recreates the default organization and creates a user in the same process.


Generated by Claude Code

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:identityLogin and identity — sign-up, sessions, organization membership, SSObugSomething isn't workingdomain:servicespriority:p3

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions