[PR #4484] [MERGED] feat: add getActiveRoleMember #13652

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

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/4484
Author: @fathisiddiqi
Created: 9/6/2025
Status: Merged
Merged: 9/9/2025
Merged by: @himself65

Base: canaryHead: feat/add-plugins-organization-useActiveMemberRole


📝 Commits (9)

  • 4f18d66 feat: implement endpoint for getActiveMemberRole
  • 4544c8d feat: initialize client for activeMemberRole
  • e7d1ca2 docs: add documentation for get active role member
  • b7d3e90 fix: resolve pr comments
  • dfff5b0 Merge branch 'canary' into feat/add-plugins-organization-useActiveMemberRole
  • ca12c6c fix: remove unnecessary logs
  • 6fc49b8 fix: fix lint problem
  • 4391e02 Merge branch 'canary' into feat/add-plugins-organization-useActiveMemberRole
  • b918aee Delete demo/nextjs/better-auth_migrations/2025-09-06T06-40-12.300Z.sql

📊 Changes

6 files changed (+206 additions, -0 deletions)

View changed files

📝 demo/nextjs/lib/auth-client.ts (+2 -0)
📝 docs/content/docs/plugins/organization.mdx (+15 -0)
📝 packages/better-auth/src/plugins/organization/client.ts (+18 -0)
📝 packages/better-auth/src/plugins/organization/organization.ts (+17 -0)
📝 packages/better-auth/src/plugins/organization/routes/crud-members.test.ts (+97 -0)
📝 packages/better-auth/src/plugins/organization/routes/crud-members.ts (+57 -0)

📄 Description

This PR is based on issue #4358 that created by xmlking

The implementation is to get the current member role of the active organization.

In this PR I've done some stuffs:
[v] api endpoint for /organization/get-active-member-role
[v] client instance of getActiveRoleMember
[v] hook of useGetActiveRoleMember


Summary by cubic

Adds GET /organization/get-active-member-role and client support to fetch a user’s role in the active organization. Enables role-based UI and checks, with optional user/organization overrides.

  • New Features
    • Server: GET /organization/get-active-member-role returns { role } for the current user’s active org by default; supports query.userId and query.organizationId; returns errors for no active org or non-members.
    • Client: Added organization.getActiveMemberRole(...) and a reactive query for UI consumption.
    • Tests: Added coverage for owner role (current user) and member role (via userId).
    • Docs: Added usage docs for fetching the active member 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/4484 **Author:** [@fathisiddiqi](https://github.com/fathisiddiqi) **Created:** 9/6/2025 **Status:** ✅ Merged **Merged:** 9/9/2025 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `feat/add-plugins-organization-useActiveMemberRole` --- ### 📝 Commits (9) - [`4f18d66`](https://github.com/better-auth/better-auth/commit/4f18d666809d567e76a6eeb73815102dcd68d243) feat: implement endpoint for getActiveMemberRole - [`4544c8d`](https://github.com/better-auth/better-auth/commit/4544c8d57da85806db6ad1e4fce96973f2ff689a) feat: initialize client for activeMemberRole - [`e7d1ca2`](https://github.com/better-auth/better-auth/commit/e7d1ca21a9c4d552373df97e81aec607ab6dc4e7) docs: add documentation for get active role member - [`b7d3e90`](https://github.com/better-auth/better-auth/commit/b7d3e90a4d043e8db0ccf528579c0f00d14ec692) fix: resolve pr comments - [`dfff5b0`](https://github.com/better-auth/better-auth/commit/dfff5b0f92646070f13d8816388d456d7e8aa22e) Merge branch 'canary' into feat/add-plugins-organization-useActiveMemberRole - [`ca12c6c`](https://github.com/better-auth/better-auth/commit/ca12c6ce14b01f89bca7b0751f96ab5721e4f0d0) fix: remove unnecessary logs - [`6fc49b8`](https://github.com/better-auth/better-auth/commit/6fc49b8f073ee425961bc15c2093e53836e56c40) fix: fix lint problem - [`4391e02`](https://github.com/better-auth/better-auth/commit/4391e02fca880125dfc04d2a507fe30e5b1cb84d) Merge branch 'canary' into feat/add-plugins-organization-useActiveMemberRole - [`b918aee`](https://github.com/better-auth/better-auth/commit/b918aee7a33b32bfa553c88cb9ca60ffd6e04288) Delete demo/nextjs/better-auth_migrations/2025-09-06T06-40-12.300Z.sql ### 📊 Changes **6 files changed** (+206 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `demo/nextjs/lib/auth-client.ts` (+2 -0) 📝 `docs/content/docs/plugins/organization.mdx` (+15 -0) 📝 `packages/better-auth/src/plugins/organization/client.ts` (+18 -0) 📝 `packages/better-auth/src/plugins/organization/organization.ts` (+17 -0) 📝 `packages/better-auth/src/plugins/organization/routes/crud-members.test.ts` (+97 -0) 📝 `packages/better-auth/src/plugins/organization/routes/crud-members.ts` (+57 -0) </details> ### 📄 Description This PR is based on issue #4358 that created by [xmlking](https://github.com/xmlking) The implementation is to get the current member role of the active organization. In this PR I've done some stuffs: [v] api endpoint for `/organization/get-active-member-role` [v] client instance of `getActiveRoleMember` [v] hook of `useGetActiveRoleMember` <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Adds GET /organization/get-active-member-role and client support to fetch a user’s role in the active organization. Enables role-based UI and checks, with optional user/organization overrides. - New Features - Server: GET /organization/get-active-member-role returns { role } for the current user’s active org by default; supports query.userId and query.organizationId; returns errors for no active org or non-members. - Client: Added organization.getActiveMemberRole(...) and a reactive query for UI consumption. - Tests: Added coverage for owner role (current user) and member role (via userId). - Docs: Added usage docs for fetching the active member role. <!-- 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 09:02: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#13652