feat: several owners per organization, and handing ownership over #142

Merged
Sebi merged 1 commits from feat/owners into main 2026-11-23 21:40:50 +00:00
Owner

Builds on #141 (account deletion and consent); merge that first, then this diff shrinks to the ownership change.

Several owners: migration 00047 drops memberships_one_owner_idx (down migration keeps the longest-standing owner per organization).

PUT /api/v1/org/members/:user/owner {"owner": true|false} — owners only (403 owner_only), session only, audited as member.owner:

  • make a member owner, take it back, or step down yourself;
  • the last owner cannot step down (409 last_owner); changes take a per-organization advisory lock, so two owners stepping down at once cannot leave none;
  • a former owner without any role assignment gets the built-in Admin role, so they keep working.
  • Handing over = make someone else owner, then step down. Owners still cannot be removed as members while they are owners (owner_cannot_be_removed, message now says to take ownership away first).

Account deletion: deletes only organizations the account is the last owner of (owner count re-checked under the same lock), leaves those with further owners. The warning before the delete button lists only those organizations and suggests making someone else owner first.

Members page: for owners, Make owner on members, Remove as owner on other owners, Step down as owner on themselves — each only while another owner remains — with confirmations. Intro text explains owners.

Tests: new TestOwners (non-owner refused, last owner refused, promote, new owner manages the org, owner cannot be removed, step down → Admin role and still working, former owner cannot promote itself, deletion with a co-owner keeps the org, last owner's deletion takes it); tenant test turned into "several owners allowed". Full suite and lint green. Dev env on :8080 migrated (00047) and restarted.

🤖 Generated with Claude Code

https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3

> Builds on #141 (account deletion and consent); merge that first, then this diff shrinks to the ownership change. **Several owners**: migration 00047 drops `memberships_one_owner_idx` (down migration keeps the longest-standing owner per organization). **`PUT /api/v1/org/members/:user/owner`** `{"owner": true|false}` — owners only (`403 owner_only`), session only, audited as `member.owner`: - make a member owner, take it back, or step down yourself; - the last owner cannot step down (`409 last_owner`); changes take a per-organization advisory lock, so two owners stepping down at once cannot leave none; - a former owner without any role assignment gets the built-in Admin role, so they keep working. - Handing over = make someone else owner, then step down. Owners still cannot be removed as members while they are owners (`owner_cannot_be_removed`, message now says to take ownership away first). **Account deletion**: deletes only organizations the account is the **last** owner of (owner count re-checked under the same lock), leaves those with further owners. The warning before the delete button lists only those organizations and suggests making someone else owner first. **Members page**: for owners, *Make owner* on members, *Remove as owner* on other owners, *Step down as owner* on themselves — each only while another owner remains — with confirmations. Intro text explains owners. **Tests**: new `TestOwners` (non-owner refused, last owner refused, promote, new owner manages the org, owner cannot be removed, step down → Admin role and still working, former owner cannot promote itself, deletion with a co-owner keeps the org, last owner's deletion takes it); tenant test turned into "several owners allowed". Full suite and lint green. Dev env on :8080 migrated (00047) and restarted. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
Sebi added 2 commits 2026-11-23 21:38:18 +00:00
feat: terms of service and versioned consent; data rights for every account
ci / test (push) Skipped
ci / build (push) Skipped
ci / image (push) Skipped
ci / lint (pull_request) Successful in 9m21s
ci / lint (push) Skipped
ci / image (pull_request) Successful in 4m36s
ci / test (pull_request) Successful in 13m53s
ci / build (pull_request) Successful in 11m22s
8d7c1f856c
Terms of service join the legal notice and privacy policy, for the
platform only. Every account accepts the platform's privacy policy and
terms: on sign-up (also through an invitation) by ticking a box for the
versions shown, and after a sign-in through a provider right away. When
an admin saves a material change with "everyone has to accept again",
the document gets a new version and each account is asked at its next
request; corrections ask nobody. Acceptances are kept per version with
their time, as proof, and are part of the data export.

Until an account accepted, and while it is suspended, it can read the
documents, export its data, delete itself and sign out, nothing else:
pages lead to /consent or /account/suspended, other API calls answer 403
consent_required or account_suspended. Suspended accounts therefore sign
in again, by password or provider; their API tokens stay blocked.

Deleting an account deletes the organizations it owns, monitors and all,
also when they have other members (each organization has one owner); it
no longer refuses. The account settings name those organizations first.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
feat: several owners per organization, and handing ownership over
ci / lint (push) Skipped
ci / test (push) Skipped
ci / build (push) Skipped
ci / image (push) Skipped
ci / build (pull_request) Successful in 15m40s
ci / image (pull_request) Successful in 4m26s
ci / lint (pull_request) Successful in 9m19s
ci / test (pull_request) Successful in 9m25s
db3ff19983
An organization may now have several owners; the unique index allowing
only one is gone. Owners make members owners or take it back, their own
included, through PUT /api/v1/org/members/:user/owner; handing an
organization over is making someone else owner and stepping down. The
last owner cannot step down, and changes serialize on a per-organization
lock so two owners stepping down at once cannot leave none. A former
owner without roles keeps working as Admin. Owners still cannot be
removed while they are owners.

Deleting an account now takes along only the organizations it is the
last owner of, counted under the same lock; it just leaves those with
further owners. The members page offers "Make owner", "Remove as owner"
and "Step down as owner" to owners.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
Sebi merged commit 6f0cf59406 into main 2026-11-23 21:40:50 +00:00
Sebi deleted branch feat/owners 2026-11-23 21:40:52 +00:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: ZB-Server/uptimesebi#142