[PR #3426] [MERGED] fix(organization): allow org owner to update their own roles #21715

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

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/3426
Author: @frectonz
Created: 7/17/2025
Status: Merged
Merged: 7/18/2025
Merged by: @Bekacru

Base: mainHead: fix/allow-org-owner-to-update-roles


📝 Commits (2)

  • 578c66c fix: allow org owner to update their own roles
  • 820651d fix(org): move the is creator check to the hasPermissions function to make it more reusable

📊 Changes

3 files changed (+192 additions, -6 deletions)

View changed files

📝 packages/better-auth/src/plugins/organization/has-permission.ts (+9 -0)
📝 packages/better-auth/src/plugins/organization/organization.test.ts (+172 -0)
📝 packages/better-auth/src/plugins/organization/routes/crud-members.ts (+11 -6)

📄 Description

Closes #3010

Instead of only allowing users with the member:update permission to update roles, this PR also checks if the user who is updating the role has the creatorRole in which case they are allowed to update the role of the given user.

This also means that a owner of an org is allowed to remove their own creatorRole which may or may not be sth we want.


Summary by cubic

Org owners can now update their own roles, including adding or removing the owner role, without needing extra permissions.

  • Bug Fixes
    • Updated role update checks to allow org owners to change their own roles.
    • Added tests to cover owner role updates and edge cases.

🔄 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/3426 **Author:** [@frectonz](https://github.com/frectonz) **Created:** 7/17/2025 **Status:** ✅ Merged **Merged:** 7/18/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `main` ← **Head:** `fix/allow-org-owner-to-update-roles` --- ### 📝 Commits (2) - [`578c66c`](https://github.com/better-auth/better-auth/commit/578c66cb5f20f3c42778849c2a67d95f9c9ea2c3) fix: allow org owner to update their own roles - [`820651d`](https://github.com/better-auth/better-auth/commit/820651dfd09245192f0492a52353ab75a79976f9) fix(org): move the `is creator` check to the `hasPermissions` function to make it more reusable ### 📊 Changes **3 files changed** (+192 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/plugins/organization/has-permission.ts` (+9 -0) 📝 `packages/better-auth/src/plugins/organization/organization.test.ts` (+172 -0) 📝 `packages/better-auth/src/plugins/organization/routes/crud-members.ts` (+11 -6) </details> ### 📄 Description Closes #3010 Instead of only allowing users with the `member:update` permission to update roles, this PR also checks if the user who is updating the `role` has the `creatorRole` in which case they are allowed to update the `role` of the given user. This also means that a owner of an org is allowed to remove their own `creatorRole` which may or may not be sth we want. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Org owners can now update their own roles, including adding or removing the owner role, without needing extra permissions. - **Bug Fixes** - Updated role update checks to allow org owners to change their own roles. - Added tests to cover owner role updates and edge cases. <!-- 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:33:20 -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#21715