[PR #1907] [MERGED] feat(admin): Add support for passing multiple roles as array #20962

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

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/1907
Author: @Netrifier
Created: 3/20/2025
Status: Merged
Merged: 4/1/2025
Merged by: @Bekacru

Base: mainHead: feat-admin-support-multiple-role-array


📝 Commits (6)

  • 64ff07a feat: add support for passing multiple roles as array
  • 42f3002 docs(admin): update docs
  • fb7888e fix(admin): Fix admin role types not referenced correctly when custom roles are not passed
  • 90eb4b9 test(admin): add test for multiple roles
  • 949e89d Merge branch 'better-auth:main' into feat-admin-support-multiple-role-array
  • fa2af72 fix(admin): Fix duplicate exports of InferRolesFromOption and parseRoles from admin and organization plugin

📊 Changes

4 files changed (+119 additions, -14 deletions)

View changed files

📝 docs/content/docs/plugins/admin.mdx (+6 -2)
📝 packages/better-auth/src/plugins/admin/admin.test.ts (+56 -0)
📝 packages/better-auth/src/plugins/admin/admin.ts (+54 -9)
📝 packages/better-auth/src/plugins/admin/client.ts (+3 -3)

📄 Description

  • Added ability to pass multiple roles as array to createUser and setRole in addition to single role as string
  • Added InferAdminRolesFromOption type to provide roles type inference in functions
  • Made roles optional in AdminClientOptions type to fix roles not being referenced when custom roles where not passed to plugin
  • Added tests to check multiple roles with createUser and setRole
  • Updated docs

Tests

image
image


🔄 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/1907 **Author:** [@Netrifier](https://github.com/Netrifier) **Created:** 3/20/2025 **Status:** ✅ Merged **Merged:** 4/1/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `main` ← **Head:** `feat-admin-support-multiple-role-array` --- ### 📝 Commits (6) - [`64ff07a`](https://github.com/better-auth/better-auth/commit/64ff07a3165329bb4106515559135388adb4a7dd) feat: add support for passing multiple roles as array - [`42f3002`](https://github.com/better-auth/better-auth/commit/42f300257a3178f6ab0de47b8b5e5b226ab7223c) docs(admin): update docs - [`fb7888e`](https://github.com/better-auth/better-auth/commit/fb7888eb3a607baeb9e793087d557d6aac657f46) fix(admin): Fix admin role types not referenced correctly when custom roles are not passed - [`90eb4b9`](https://github.com/better-auth/better-auth/commit/90eb4b9c93cb7204dd994d8818d37a0c143e529a) test(admin): add test for multiple roles - [`949e89d`](https://github.com/better-auth/better-auth/commit/949e89df2d97adc8de6efaf2a55d1e5f6d0860d9) Merge branch 'better-auth:main' into feat-admin-support-multiple-role-array - [`fa2af72`](https://github.com/better-auth/better-auth/commit/fa2af725771510fa59760723f61e47f926cd7b84) fix(admin): Fix duplicate exports of InferRolesFromOption and parseRoles from admin and organization plugin ### 📊 Changes **4 files changed** (+119 additions, -14 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/plugins/admin.mdx` (+6 -2) 📝 `packages/better-auth/src/plugins/admin/admin.test.ts` (+56 -0) 📝 `packages/better-auth/src/plugins/admin/admin.ts` (+54 -9) 📝 `packages/better-auth/src/plugins/admin/client.ts` (+3 -3) </details> ### 📄 Description - Added ability to pass multiple roles as array to `createUser` and `setRole` in addition to single role as string - Added `InferAdminRolesFromOption` type to provide roles type inference in functions - Made roles optional in `AdminClientOptions` type to fix roles not being referenced when custom roles where not passed to plugin - Added tests to check multiple roles with `createUser` and `setRole` - Updated docs ## Tests ![image](https://github.com/user-attachments/assets/48f1215b-dff5-40fc-a96e-863a8d4e915e) ![image](https://github.com/user-attachments/assets/3861c2be-ac12-46f8-9f15-7c6720becb1b) --- <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:02:27 -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#20962