[PR #3955] [MERGED] fix(organization): was possible to remove sole org owner #22005

Closed
opened 2026-04-15 20:44:49 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/3955
Author: @gwoodbridge
Created: 8/12/2025
Status: Merged
Merged: 9/2/2025
Merged by: @himself65

Base: canaryHead: fix/organization-with-no-owner-possible


📝 Commits (7)

  • 2cfc145 fix organization with no owner
  • a20182c Update packages/better-auth/src/plugins/organization/error-codes.ts
  • b15edd7 Merge branch 'better-auth:canary' into fix/organization-with-no-owner-possible
  • 28b81f8 Remove listMember call and fix owner role check in leaveOrganization
  • d5f284e Merge branch 'fix/organization-with-no-owner-possible' of https://github.com/gwoodbridge/better-auth into fix/organization-with-no-owner-possible
  • 4813b93 Merge remote-tracking branch 'origin/canary' into fix/organization-with-no-owner-possible
  • c3f9d4f Fix test

📊 Changes

4 files changed (+82 additions, -21 deletions)

View changed files

📝 packages/better-auth/src/plugins/organization/error-codes.ts (+3 -1)
📝 packages/better-auth/src/plugins/organization/organization.test.ts (+51 -8)
📝 packages/better-auth/src/plugins/organization/routes/crud-access-control.test.ts (+0 -7)
📝 packages/better-auth/src/plugins/organization/routes/crud-members.ts (+28 -5)

📄 Description

Removed possibility of removing the sole org owner by checking if the user calling update-member-role is an owner, if there is only one owner, if they are updating their own roles, and if they are not including an owner/creator role and then throwing a new error message.

Fixes #3651


Summary by cubic

Prevented removal of the sole organization owner to ensure every organization always has at least one owner, addressing Linear issue #3651.

  • Bug Fixes
  • Added a check to block owners from removing their own owner role if they are the only owner.
  • Updated error messages for clarity.
  • Added tests to cover this scenario.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/3955 **Author:** [@gwoodbridge](https://github.com/gwoodbridge) **Created:** 8/12/2025 **Status:** ✅ Merged **Merged:** 9/2/2025 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `fix/organization-with-no-owner-possible` --- ### 📝 Commits (7) - [`2cfc145`](https://github.com/better-auth/better-auth/commit/2cfc145a85ccc0eb6ab0fc04a16ad735fc4df010) fix organization with no owner - [`a20182c`](https://github.com/better-auth/better-auth/commit/a20182cb4f991c266b47b4bea4a59455f41c86c2) Update packages/better-auth/src/plugins/organization/error-codes.ts - [`b15edd7`](https://github.com/better-auth/better-auth/commit/b15edd7ff9d55313aedc2156b59af036d74ebdd7) Merge branch 'better-auth:canary' into fix/organization-with-no-owner-possible - [`28b81f8`](https://github.com/better-auth/better-auth/commit/28b81f895557b937f5ea0a3ecc22a1f683e9276f) Remove listMember call and fix owner role check in leaveOrganization - [`d5f284e`](https://github.com/better-auth/better-auth/commit/d5f284e53be68d6653ecc1902eebbefe83d49106) Merge branch 'fix/organization-with-no-owner-possible' of https://github.com/gwoodbridge/better-auth into fix/organization-with-no-owner-possible - [`4813b93`](https://github.com/better-auth/better-auth/commit/4813b93417da6cf079615cc2dcde706bf78492b2) Merge remote-tracking branch 'origin/canary' into fix/organization-with-no-owner-possible - [`c3f9d4f`](https://github.com/better-auth/better-auth/commit/c3f9d4fb41d196bd5d24518dd73962b454c12a7d) Fix test ### 📊 Changes **4 files changed** (+82 additions, -21 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/plugins/organization/error-codes.ts` (+3 -1) 📝 `packages/better-auth/src/plugins/organization/organization.test.ts` (+51 -8) 📝 `packages/better-auth/src/plugins/organization/routes/crud-access-control.test.ts` (+0 -7) 📝 `packages/better-auth/src/plugins/organization/routes/crud-members.ts` (+28 -5) </details> ### 📄 Description Removed possibility of removing the sole org owner by checking if the user calling update-member-role is an owner, if there is only one owner, if they are updating their own roles, and if they are not including an owner/creator role and then throwing a new error message. Fixes #3651 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Prevented removal of the sole organization owner to ensure every organization always has at least one owner, addressing Linear issue #3651. - **Bug Fixes** - Added a check to block owners from removing their own owner role if they are the only owner. - Updated error messages for clarity. - Added tests to cover this scenario. <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-15 20:44:49 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#22005