[PR #4842] [MERGED] fix(admin): validate admin role updates against the configured roles to prevent setting a non-existent role #5608

Closed
opened 2026-03-13 12:29:17 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/4842
Author: @hieudien14310
Created: 9/23/2025
Status: Merged
Merged: 10/22/2025
Merged by: @Bekacru

Base: canaryHead: fix/admin-set-role


📝 Commits (7)

  • 0f6a6cc fix: verify role as valid before update
  • 8d7e6fa fix: check case is array
  • 8b4ec09 fix: add test case
  • 08138d9 Merge branch 'canary' into fix/admin-set-role
  • a10832b Merge branch 'canary' into fix/admin-set-role
  • ae2081b Merge branch 'canary' into fix/admin-set-role
  • cd804a8 Merge branch 'canary' into fix/admin-set-role

📊 Changes

3 files changed (+88 additions, -3 deletions)

View changed files

📝 packages/better-auth/src/plugins/admin/admin.test.ts (+72 -2)
📝 packages/better-auth/src/plugins/admin/admin.ts (+14 -1)
📝 packages/better-auth/src/plugins/admin/error-codes.ts (+2 -0)

📄 Description

Summary by cubic

Validate admin role updates against the configured roles to prevent setting a non-existent role. If the role is invalid, the request returns BAD_REQUEST.

  • Bug Fixes
    • Check opts.roles for the provided role before updating.
    • Add ADMIN_ERROR_CODES.YOU_ARE_NOT_ALLOWED_TO_SET_NON_EXISTENT_VALUE.

🔄 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/4842 **Author:** [@hieudien14310](https://github.com/hieudien14310) **Created:** 9/23/2025 **Status:** ✅ Merged **Merged:** 10/22/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `canary` ← **Head:** `fix/admin-set-role` --- ### 📝 Commits (7) - [`0f6a6cc`](https://github.com/better-auth/better-auth/commit/0f6a6cc9af047ed2b04b7982fc63420c57b81630) fix: verify role as valid before update - [`8d7e6fa`](https://github.com/better-auth/better-auth/commit/8d7e6faa8272b5d5f596d1b10a42792651fd2ef9) fix: check case is array - [`8b4ec09`](https://github.com/better-auth/better-auth/commit/8b4ec09ecdcd10515905ffe46fb9bd09b48934fe) fix: add test case - [`08138d9`](https://github.com/better-auth/better-auth/commit/08138d9a6b273ac32b2f68456fbf33537cc971dd) Merge branch 'canary' into fix/admin-set-role - [`a10832b`](https://github.com/better-auth/better-auth/commit/a10832b093b38579a0a5591f84533e10913afb4f) Merge branch 'canary' into fix/admin-set-role - [`ae2081b`](https://github.com/better-auth/better-auth/commit/ae2081b25002a97217dee777d48407d8e670899d) Merge branch 'canary' into fix/admin-set-role - [`cd804a8`](https://github.com/better-auth/better-auth/commit/cd804a8ae5d4ff19dcbbdd1b1d5bab265e466790) Merge branch 'canary' into fix/admin-set-role ### 📊 Changes **3 files changed** (+88 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/plugins/admin/admin.test.ts` (+72 -2) 📝 `packages/better-auth/src/plugins/admin/admin.ts` (+14 -1) 📝 `packages/better-auth/src/plugins/admin/error-codes.ts` (+2 -0) </details> ### 📄 Description <!-- This is an auto-generated description by cubic. --> ## Summary by cubic Validate admin role updates against the configured roles to prevent setting a non-existent role. If the role is invalid, the request returns BAD_REQUEST. - **Bug Fixes** - Check opts.roles for the provided role before updating. - Add ADMIN_ERROR_CODES.YOU_ARE_NOT_ALLOWED_TO_SET_NON_EXISTENT_VALUE. <!-- 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-03-13 12:29:17 -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#5608