[PR #6732] Add role property to organization list response #23755

Open
opened 2026-04-15 21:57:24 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/6732
Author: @Ridhim-RR
Created: 12/13/2025
Status: 🔄 Open

Base: mainHead: feat/organization-role-in-user-orgs-list


📝 Commits (6)

  • f2066a6 feat(role): user role in the org list
  • 86ec07e chore(type): type issue resolve in the test case
  • b96cb1b Merge branch 'canary' into feat/organization-role-in-user-orgs-list
  • 25d03eb fix(snapshot) snapshot mismatch resolved
  • 69314cc Merge branch 'canary' into feat/organization-role-in-user-orgs-list
  • 9d61e3a Merge branch 'canary' into feat/organization-role-in-user-orgs-list

📊 Changes

4 files changed (+196 additions, -24 deletions)

View changed files

📝 packages/better-auth/src/plugins/organization/adapter.ts (+4 -1)
📝 packages/better-auth/src/plugins/organization/client.ts (+5 -8)
📝 packages/better-auth/src/plugins/organization/organization.test.ts (+168 -14)
📝 packages/better-auth/src/plugins/organization/routes/crud-org.ts (+19 -1)

📄 Description

Closes #6723

Adds the role property to the listOrganizations API response so clients can see the user's role for each organization without an extra call.

Changes

  • Added role to listOrganizations response: each organization includes the current user's role (owner, admin, or member)
  • Make slight change in the listOrganizations in the adapter.ts which will return role along other data.
  • Added tests: functional and type tests for the new role property

Testing
• Added test case verifying role is correctly returned for owner, admin, and member users


Summary by cubic

Adds the user's role to the listOrganizations API so clients get role info (owner, admin, member) per org in one call. This removes the need for extra membership lookups and simplifies org list UIs.

  • New Features
    • listOrganizations now returns role for the requesting user on each org.
    • Role is derived from the user's membership; the field is optional for backward compatibility.

Written for commit 9d61e3abec. Summary will update automatically 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/6732 **Author:** [@Ridhim-RR](https://github.com/Ridhim-RR) **Created:** 12/13/2025 **Status:** 🔄 Open **Base:** `main` ← **Head:** `feat/organization-role-in-user-orgs-list` --- ### 📝 Commits (6) - [`f2066a6`](https://github.com/better-auth/better-auth/commit/f2066a603ee284d6fa9cae1ad9a52078276edf1a) feat(role): user role in the org list - [`86ec07e`](https://github.com/better-auth/better-auth/commit/86ec07e2ed323e66c9819bcbf67aab245b5d8217) chore(type): type issue resolve in the test case - [`b96cb1b`](https://github.com/better-auth/better-auth/commit/b96cb1b450b8a84107f98da943124fb91981ff3f) Merge branch 'canary' into feat/organization-role-in-user-orgs-list - [`25d03eb`](https://github.com/better-auth/better-auth/commit/25d03ebd0d4a0b348d66e9c18c24c0640dfac72a) fix(snapshot) snapshot mismatch resolved - [`69314cc`](https://github.com/better-auth/better-auth/commit/69314cc979a4fcf3aa977135c4dd679c5bd50dd2) Merge branch 'canary' into feat/organization-role-in-user-orgs-list - [`9d61e3a`](https://github.com/better-auth/better-auth/commit/9d61e3abecca9fa600a05e9307c3b7c14e0a5025) Merge branch 'canary' into feat/organization-role-in-user-orgs-list ### 📊 Changes **4 files changed** (+196 additions, -24 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/plugins/organization/adapter.ts` (+4 -1) 📝 `packages/better-auth/src/plugins/organization/client.ts` (+5 -8) 📝 `packages/better-auth/src/plugins/organization/organization.test.ts` (+168 -14) 📝 `packages/better-auth/src/plugins/organization/routes/crud-org.ts` (+19 -1) </details> ### 📄 Description Closes #6723 Adds the role property to the listOrganizations API response so clients can see the user's role for each organization without an extra call. **Changes** - Added role to listOrganizations response: each organization includes the current user's role (owner, admin, or member) - Make slight change in the listOrganizations in the adapter.ts which will return role along other data. - Added tests: functional and type tests for the new role property **Testing** • Added test case verifying role is correctly returned for owner, admin, and member users <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Adds the user's role to the listOrganizations API so clients get role info (owner, admin, member) per org in one call. This removes the need for extra membership lookups and simplifies org list UIs. - **New Features** - listOrganizations now returns role for the requesting user on each org. - Role is derived from the user's membership; the field is optional for backward compatibility. <sup>Written for commit 9d61e3abecca9fa600a05e9307c3b7c14e0a5025. Summary will update automatically 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-15 21:57:24 -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#23755