[PR #8442] [MERGED] fix(organization): handle multi-role users in invite and member removal checks #16223

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

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/8442
Author: @himself65
Created: 3/6/2026
Status: Merged
Merged: 3/6/2026
Merged by: @himself65

Base: canaryHead: fix/org-multi-role-invite-check


📝 Commits (5)

  • 6b5b9da fix(organization): handle multi-role users in invite and member removal checks
  • 46e5b63 Potential fix for pull request finding 'Unused variable, import, function or class'
  • c2b14cc fix: address review feedback - trim roles, remove unused var, assert update
  • 7ca31d4 style: fix biome formatting
  • 6887079 fix: add non-null assertion for members[0] to fix typecheck

📊 Changes

3 files changed (+45 additions, -2 deletions)

View changed files

📝 packages/better-auth/src/plugins/organization/organization.test.ts (+35 -0)
📝 packages/better-auth/src/plugins/organization/routes/crud-invites.ts (+4 -1)
📝 packages/better-auth/src/plugins/organization/routes/crud-members.ts (+6 -1)

📄 Description

Summary

  • Fixed member.role !== creatorRole checks that used strict string equality instead of splitting comma-separated roles
  • A user with role "owner,admin" was incorrectly denied permission to invite with the owner role because "owner,admin" !== "owner"
  • Applied the same fix to the member removal path in crud-members.ts

Fixes #8385

Test plan

  • Added regression test: multi-role owner can invite with owner role
  • All 90 organization tests pass
  • All 18 crud-members tests pass

🔄 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/8442 **Author:** [@himself65](https://github.com/himself65) **Created:** 3/6/2026 **Status:** ✅ Merged **Merged:** 3/6/2026 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `fix/org-multi-role-invite-check` --- ### 📝 Commits (5) - [`6b5b9da`](https://github.com/better-auth/better-auth/commit/6b5b9da669b8ab61f47a80eb0e3d3d7764fb2186) fix(organization): handle multi-role users in invite and member removal checks - [`46e5b63`](https://github.com/better-auth/better-auth/commit/46e5b6333401d083936644aa9d722292ad4592f9) Potential fix for pull request finding 'Unused variable, import, function or class' - [`c2b14cc`](https://github.com/better-auth/better-auth/commit/c2b14cc5290b8da66e8db3decb6f0a9b2252dc4b) fix: address review feedback - trim roles, remove unused var, assert update - [`7ca31d4`](https://github.com/better-auth/better-auth/commit/7ca31d4a4df29db50d436272669fd5ebd94dc42d) style: fix biome formatting - [`6887079`](https://github.com/better-auth/better-auth/commit/688707951503b55cdd0b2ab9edda39a708cb612a) fix: add non-null assertion for members[0] to fix typecheck ### 📊 Changes **3 files changed** (+45 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/plugins/organization/organization.test.ts` (+35 -0) 📝 `packages/better-auth/src/plugins/organization/routes/crud-invites.ts` (+4 -1) 📝 `packages/better-auth/src/plugins/organization/routes/crud-members.ts` (+6 -1) </details> ### 📄 Description ## Summary - Fixed `member.role !== creatorRole` checks that used strict string equality instead of splitting comma-separated roles - A user with role `"owner,admin"` was incorrectly denied permission to invite with the `owner` role because `"owner,admin" !== "owner"` - Applied the same fix to the member removal path in `crud-members.ts` Fixes #8385 ## Test plan - [x] Added regression test: multi-role owner can invite with owner role - [x] All 90 organization tests pass - [x] All 18 crud-members tests pass --- <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:26:59 -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#16223