feat(tenancy): the administrators of a tenant invite people to it #51

Merged
crapougnax merged 2 commits from feat/49-tenant-members into develop 2026-11-18 21:00:28 +00:00
Owner

Closes #49 (step 2; step 1 was #50).

Two roles, two ways in:

  • Instance administrator (System): adds an existing account to a tenant directly, choosing it among all the accounts of the instance (searchable selector on the Tenants page, unchanged).
  • Tenant administrator: invites a person by address from the Members page of the tenant. Nothing tells whether the address has an account elsewhere on the instance; only an address already in the tenant is refused, with a warning as it is typed.

Changes

  • Members page (/t/<tenant>/members, Configuration section, tenant administrators only): members with their roles, role change, removal; pending invitations with withdrawal; invitation form (address + roles).
  • Invitations (migrations/0004_tenant_invitations.sql, tenant-invitations.ts): (tenant, email, roles, invited_by, created_at). An invitation shows the address only and answers alike whether the instance knows it or not.
  • Admission: an invitation becomes a membership when an account carrying that address comes, i.e. whenever its tenants are listed (every page) and on the home after sign-in. The address counts when the instance vouches for it: the login of a local account (created by an instance administrator) or the address the identity provider verified. A disabled account is admitted nowhere; an account already member keeps its roles.
  • No account is created from a tenant: accounts come from the identity provider at first sign-in, or from an instance administrator.
  • Routes inside the tenant scope, for its administrators: GET /api/tenant/members (members and invitations), PUT|DELETE /api/tenant/members/<account>, POST /api/tenant/invitations, DELETE /api/tenant/invitations/<email>. PUT only changes the roles of an existing member, so an account cannot be pulled into a tenant by its identifier.
  • A tenant keeps at least one administrator, from the tenant and from System (409).
  • Grants: the application role gets SELECT, INSERT, UPDATE, DELETE on tenant_invitations (yarn admin migrate applies it).
  • Docs: multi-tenancy (section 5), EN/FR.

Verification

  • yarn test: 191 tests pass (invitation alike for known and unknown addresses, refusal of an address already in the tenant, admission at the coming of the account, disabled accounts, last administrator, routing, form warning).
  • The migration and the SQL of PostgresInvitationStore were run against the local PostgreSQL container inside a rolled-back transaction.
  • yarn build passes; tsc shows no new error.
  • Not checked in a browser (no local stack, #9).

Deployment

Run yarn admin migrate (or node bin/studio-admin.ts migrate in the image) before serving: the members page reads tenant_invitations.

🤖 Generated with Claude Code

Closes #49 (step 2; step 1 was #50). Two roles, two ways in: - **Instance administrator (System)**: adds an existing account to a tenant directly, choosing it among all the accounts of the instance (searchable selector on the Tenants page, unchanged). - **Tenant administrator**: **invites** a person by address from the Members page of the tenant. Nothing tells whether the address has an account elsewhere on the instance; only an address already in the tenant is refused, with a warning as it is typed. ## Changes - **Members page** (`/t/<tenant>/members`, Configuration section, tenant administrators only): members with their roles, role change, removal; pending invitations with withdrawal; invitation form (address + roles). - **Invitations** (`migrations/0004_tenant_invitations.sql`, `tenant-invitations.ts`): `(tenant, email, roles, invited_by, created_at)`. An invitation shows the address only and answers alike whether the instance knows it or not. - **Admission**: an invitation becomes a membership when an account carrying that address comes, i.e. whenever its tenants are listed (every page) and on the home after sign-in. The address counts when the instance vouches for it: the login of a local account (created by an instance administrator) or the address the identity provider verified. A disabled account is admitted nowhere; an account already member keeps its roles. - **No account is created from a tenant**: accounts come from the identity provider at first sign-in, or from an instance administrator. - **Routes** inside the tenant scope, for its administrators: `GET /api/tenant/members` (members and invitations), `PUT|DELETE /api/tenant/members/<account>`, `POST /api/tenant/invitations`, `DELETE /api/tenant/invitations/<email>`. `PUT` only changes the roles of an existing member, so an account cannot be pulled into a tenant by its identifier. - **A tenant keeps at least one administrator**, from the tenant and from System (`409`). - Grants: the application role gets `SELECT, INSERT, UPDATE, DELETE` on `tenant_invitations` (`yarn admin migrate` applies it). - Docs: multi-tenancy (section 5), EN/FR. ## Verification - `yarn test`: 191 tests pass (invitation alike for known and unknown addresses, refusal of an address already in the tenant, admission at the coming of the account, disabled accounts, last administrator, routing, form warning). - The migration and the SQL of `PostgresInvitationStore` were run against the local PostgreSQL container inside a rolled-back transaction. - `yarn build` passes; `tsc` shows no new error. - Not checked in a browser (no local stack, #9). ## Deployment Run `yarn admin migrate` (or `node bin/studio-admin.ts migrate` in the image) before serving: the members page reads `tenant_invitations`. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
feat(tenancy): the administrators of a tenant manage its members (#49)
All checks were successful
Build and Publish OCI Image / Build & Push ARM64 OCI Image (pull_request) Successful in 56s
bc47196180
A Members page in the configuration of a tenant, for its administrators:
list the members, change their roles, remove them, and add a person by exact
address. An account carrying the address becomes a member; for an address the
instance does not know, a local account is created and its provisional
password is shown once. The accounts of the instance are never listed there.

- Tenant routes /api/tenant/members and /api/tenant/members/<account>,
  served inside the tenant scope, for its administrators only. Changing roles
  never makes a member of an account: people are added by address only.
- New accounts follow ALLOWED_EMAIL_DOMAINS; an address carried by several
  accounts is refused.
- A tenant keeps at least one administrator, from the tenant and from System.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
feat(tenancy): the administrators of a tenant invite people by address (#49)
All checks were successful
Build and Publish OCI Image / Build & Push ARM64 OCI Image (pull_request) Successful in 59s
7fb9d8101e
Adding a member by address told a tenant administrator whether the instance
knew the address, and showed a password only for a new account. A tenant
administrator now invites an address instead: the answer is the same whether
the instance knows it or not, and only an address already in the tenant is
refused, with a warning as it is typed.

- The invitation waits in tenant_invitations, showing the address only, and
  becomes a membership when an account carrying that address comes: when its
  tenants are listed, and on the home after sign-in. The login of a local
  account and the address the provider verified count.
- The Studio creates no account from a tenant any more: accounts come from the
  identity provider or from an administrator of the instance, who keeps adding
  existing accounts directly from System.
- Routes: POST /api/tenant/invitations, DELETE /api/tenant/invitations/<email>;
  GET /api/tenant/members lists the invitations too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
crapougnax changed title from feat(tenancy): the administrators of a tenant manage its members to feat(tenancy): the administrators of a tenant invite people to it 2026-11-18 20:57:21 +00:00
crapougnax merged commit b894a2214f into develop 2026-11-18 21:00:28 +00:00
crapougnax deleted branch feat/49-tenant-members 2026-11-18 21:00:28 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
modaka/studio!51
No description provided.