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 / lint (pull_request) Successful in 9m19s
ci / test (pull_request) Successful in 9m25s
ci / build (pull_request) Successful in 15m40s
ci / image (pull_request) Successful in 4m26s
ci / lint (push) Skipped
ci / test (push) Skipped
ci / build (push) Skipped
ci / image (push) Skipped
ci / lint (pull_request) Successful in 9m19s
ci / test (pull_request) Successful in 9m25s
ci / build (pull_request) Successful in 15m40s
ci / image (pull_request) Successful in 4m26s
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
This commit is contained in:
1 parent
8d7c1f856c
commit
db3ff19983
23 files changed
+558
-115
No files matched your search
+17
-5
@@ -603,9 +603,9 @@ func purgeOrg(ctx context.Context, q *store.Queries, org uuid.UUID) error {
|
||||
}
|
||||
|
||||
// deleteAccount erases the signed-in user (Art. 17). Organizations the
|
||||
// user owns go with the account, monitors and all, even when they have
|
||||
// other members: an organization has exactly one owner, and nobody would be
|
||||
// left to run it.
|
||||
// user is the last owner of go with the account, monitors and all, even
|
||||
// when they have other members: nobody would be left to run them. The user
|
||||
// just leaves organizations with further owners.
|
||||
// Suspended accounts and those that have not accepted the terms may do
|
||||
// this too.
|
||||
func (s *Server) deleteAccount(c *gin.Context) {
|
||||
@@ -640,8 +640,8 @@ func (s *Server) deleteAccount(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{"status": "deleted"})
|
||||
}
|
||||
|
||||
// eraseAccount deletes u with the organizations u owns and ends u's
|
||||
// sessions; u leaves the others.
|
||||
// eraseAccount deletes u with the organizations u is the last owner of and
|
||||
// ends u's sessions; u leaves the others.
|
||||
func (s *Server) eraseAccount(ctx context.Context, u store.User) (orgsDeleted int, err error) {
|
||||
err = s.db.Tx(ctx, tenant.System(), func(q *store.Queries) error {
|
||||
owned, err := q.OwnedOrgs(ctx, u.ID)
|
||||
@@ -649,6 +649,18 @@ func (s *Server) eraseAccount(ctx context.Context, u store.User) (orgsDeleted in
|
||||
return err
|
||||
}
|
||||
for _, o := range owned {
|
||||
if err := q.LockOrgOwners(ctx, o.ID); err != nil {
|
||||
return err
|
||||
}
|
||||
// Counted again under the lock: another owner may be stepping
|
||||
// down right now.
|
||||
n, err := q.CountOwners(ctx, o.ID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if n > 1 {
|
||||
continue
|
||||
}
|
||||
if err := purgeOrg(ctx, q, o.ID); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user