[PR #1088] [MERGED] fix(organization): limit creator role invites to users with same role #29224

Closed
opened 2026-04-17 20:35:56 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/1088
Author: @emqMalte
Created: 1/1/2025
Status: Merged
Merged: 1/1/2025
Merged by: @Bekacru

Base: mainHead: main


📝 Commits (2)

  • dc8abc7 fix: invites for creatorRole only allowed by creatorRole holders
  • 6c771b6 test: add tests for invites of users with each default role

📊 Changes

2 files changed (+95 additions, -64 deletions)

View changed files

📝 packages/better-auth/src/plugins/organization/organization.test.ts (+94 -63)
📝 packages/better-auth/src/plugins/organization/routes/crud-invites.ts (+1 -1)

📄 Description

Via the commit https://github.com/better-auth/better-auth/commit/6ab16893 a new check was introduced, with the goal to limit the assignment of the "creator" role during the sending of an invitation, so that only other users holding the "creator" role can invite new users and assign them the "creator role" as part of this invitation.

There are two conditions involved in this check:

  1. Does the user sending the invite have the "creator" role, and
  2. is the role, that is to be assigned to the new user, the "creator" role

These however are combined with an OR operator, instead of an AND.
This introduced two issues:

  1. Invites can only be sent by users holding the creator role, other roles can no longer send any invites, even when they have the correct permissions, and
  2. the "creator" role itself cannot be used as the role to be assigned to the invitee, even when the user sending the invite themselves has the "creator" role

Changes

This PR changes the operator of the check to an AND to fix both of these issues.

This PR also extends the existing "invites user to organization" test to test inviting a user with each of the three default roles ("owner", "admin", "member").
This would catch the issue where invites with the "creator" role are not possible, even when the inviting user has the "creator" role.


🔄 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/1088 **Author:** [@emqMalte](https://github.com/emqMalte) **Created:** 1/1/2025 **Status:** ✅ Merged **Merged:** 1/1/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `main` ← **Head:** `main` --- ### 📝 Commits (2) - [`dc8abc7`](https://github.com/better-auth/better-auth/commit/dc8abc7cc6f01ed3cf6ad04ea0ab9116eb445b42) fix: invites for creatorRole only allowed by creatorRole holders - [`6c771b6`](https://github.com/better-auth/better-auth/commit/6c771b61a28f8e3d7272d2810ed0edc069ee18bd) test: add tests for invites of users with each default role ### 📊 Changes **2 files changed** (+95 additions, -64 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/plugins/organization/organization.test.ts` (+94 -63) 📝 `packages/better-auth/src/plugins/organization/routes/crud-invites.ts` (+1 -1) </details> ### 📄 Description Via the commit https://github.com/better-auth/better-auth/commit/6ab16893 a new check was introduced, with the goal to limit the assignment of the "creator" role during the sending of an invitation, so that only other users holding the "creator" role can invite new users and assign them the "creator role" as part of this invitation. There are two conditions involved in this check: 1. Does the user sending the invite have the "creator" role, and 1. is the role, that is to be assigned to the new user, the "creator" role These however are combined with an OR operator, instead of an AND. This introduced two issues: 1. Invites can only be sent by users holding the creator role, other roles can no longer send any invites, even when they have the correct permissions, and 1. the "creator" role itself cannot be used as the role to be assigned to the invitee, even when the user sending the invite themselves has the "creator" role ### Changes This PR changes the operator of the check to an AND to fix both of these issues. This PR also extends the existing "invites user to organization" test to test inviting a user with each of the three default roles ("owner", "admin", "member"). This would catch the issue where invites with the "creator" role are not possible, even when the inviting user has the "creator" role. --- <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-17 20:35:56 -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#29224