[PR #7736] [MERGED] fix(organization): prevent deletion of roles assigned to members #15770

Closed
opened 2026-04-13 10:12:57 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/7736
Author: @bytaesu
Created: 2/1/2026
Status: Merged
Merged: 2/3/2026
Merged by: @himself65

Base: canaryHead: 2026-02-01/fix/org-assigned-role-deletion


📝 Commits (2)

  • 3fa5f1d fix: prevent deletion of roles assigned to members
  • 31741c4 perf: use contains operator

📊 Changes

3 files changed (+168 additions, -0 deletions)

View changed files

📝 packages/better-auth/src/plugins/organization/error-codes.ts (+2 -0)
📝 packages/better-auth/src/plugins/organization/routes/crud-access-control.test.ts (+130 -0)
📝 packages/better-auth/src/plugins/organization/routes/crud-access-control.ts (+36 -0)

📄 Description

Related to https://github.com/better-auth/better-auth/issues/7727#issuecomment-3829065189


Summary by cubic

Prevent deleting organization roles that are assigned to members. Shows a clear error and requires reassigning members before deletion.

  • Bug Fixes
    • Added server-side check in deleteOrgRole to block deletion if any member uses the role (supports single or multiple roles per member).
    • Introduced ROLE_IS_ASSIGNED_TO_MEMBERS error code with a helpful message.
    • Added tests for assigned role deletion and multi-role member scenarios.

Written for commit 31741c47fb. Summary will update on new commits.


🔄 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/7736 **Author:** [@bytaesu](https://github.com/bytaesu) **Created:** 2/1/2026 **Status:** ✅ Merged **Merged:** 2/3/2026 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `2026-02-01/fix/org-assigned-role-deletion` --- ### 📝 Commits (2) - [`3fa5f1d`](https://github.com/better-auth/better-auth/commit/3fa5f1d0849742dff1812046bb9062c5570f2ebf) fix: prevent deletion of roles assigned to members - [`31741c4`](https://github.com/better-auth/better-auth/commit/31741c47fb9927e3e37ff5ce3ba4ac6fbea03f07) perf: use contains operator ### 📊 Changes **3 files changed** (+168 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/plugins/organization/error-codes.ts` (+2 -0) 📝 `packages/better-auth/src/plugins/organization/routes/crud-access-control.test.ts` (+130 -0) 📝 `packages/better-auth/src/plugins/organization/routes/crud-access-control.ts` (+36 -0) </details> ### 📄 Description Related to https://github.com/better-auth/better-auth/issues/7727#issuecomment-3829065189 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Prevent deleting organization roles that are assigned to members. Shows a clear error and requires reassigning members before deletion. - **Bug Fixes** - Added server-side check in deleteOrgRole to block deletion if any member uses the role (supports single or multiple roles per member). - Introduced ROLE_IS_ASSIGNED_TO_MEMBERS error code with a helpful message. - Added tests for assigned role deletion and multi-role member scenarios. <sup>Written for commit 31741c47fb9927e3e37ff5ce3ba4ac6fbea03f07. Summary will update on new commits.</sup> <!-- 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-13 10:12:57 -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#15770