[PR #7016] [MERGED] fix(admin): userId check in /has-permission #32625

Closed
opened 2026-04-17 23:23:22 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/7016
Author: @himself65
Created: 12/27/2025
Status: Merged
Merged: 12/27/2025
Merged by: @himself65

Base: canaryHead: himself65/2025/12/27/check


📝 Commits (3)

  • d49869d fix(admin): userId check in /has-permission
  • 5a74736 Update packages/better-auth/src/plugins/admin/admin.test.ts
  • 26489c0 fix: test

📊 Changes

2 files changed (+105 additions, -3 deletions)

View changed files

📝 packages/better-auth/src/plugins/admin/admin.test.ts (+100 -0)
📝 packages/better-auth/src/plugins/admin/routes.ts (+5 -3)

📄 Description

Summary by cubic

Fixes /admin/has-permission to validate userId before hitting the DB, preventing undefined queries and returning accurate errors for edge cases. Adds coverage for missing, empty, and "NaN" userId, and confirms behavior with number IDs.

  • Bug Fixes
    • Only query the DB when userId is provided; otherwise require userId or role.
    • Avoid findUserById calls with undefined/empty userId.
    • Return "user not found" when userId is "NaN".

Written for commit 26489c0d56. 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/7016 **Author:** [@himself65](https://github.com/himself65) **Created:** 12/27/2025 **Status:** ✅ Merged **Merged:** 12/27/2025 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `himself65/2025/12/27/check` --- ### 📝 Commits (3) - [`d49869d`](https://github.com/better-auth/better-auth/commit/d49869d7840f215515899b717a8a934ecc85cae5) fix(admin): userId check in `/has-permission` - [`5a74736`](https://github.com/better-auth/better-auth/commit/5a7473674336339d5b3d01d49df26054da739586) Update packages/better-auth/src/plugins/admin/admin.test.ts - [`26489c0`](https://github.com/better-auth/better-auth/commit/26489c0d56c1cf9ca06821413ad224c69d8e0507) fix: test ### 📊 Changes **2 files changed** (+105 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/plugins/admin/admin.test.ts` (+100 -0) 📝 `packages/better-auth/src/plugins/admin/routes.ts` (+5 -3) </details> ### 📄 Description <!-- This is an auto-generated description by cubic. --> ## Summary by cubic Fixes /admin/has-permission to validate userId before hitting the DB, preventing undefined queries and returning accurate errors for edge cases. Adds coverage for missing, empty, and "NaN" userId, and confirms behavior with number IDs. - **Bug Fixes** - Only query the DB when userId is provided; otherwise require userId or role. - Avoid findUserById calls with undefined/empty userId. - Return "user not found" when userId is "NaN". <sup>Written for commit 26489c0d56c1cf9ca06821413ad224c69d8e0507. 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-17 23:23:23 -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#32625