[PR #5075] [MERGED] fix(admin): stricter body validation with the setUserPassword api #5755

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

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/5075
Author: @hieudien14310
Created: 10/4/2025
Status: Merged
Merged: 10/15/2025
Merged by: @Bekacru

Base: canaryHead: fix/set-user-password


📝 Commits (6)

  • 9d68712 fix(admin): validate newPassword and userId fields for non-emptiness and enforce password length constraints
  • c6457ab fix(admin): add tests
  • 351f97a fix
  • 3daf75d fix(admin): coerce userId to string and ensure non-emptiness validation
  • f2f8276 Merge branch 'canary' into fix/set-user-password
  • c0647ba Merge branch 'canary' into fix/set-user-password

📊 Changes

2 files changed (+83 additions, -8 deletions)

View changed files

📝 packages/better-auth/src/plugins/admin/admin.test.ts (+56 -0)
📝 packages/better-auth/src/plugins/admin/admin.ts (+27 -8)

📄 Description

Summary by cubic

Strengthened validation for admin.setUserPassword to reject empty fields and enforce password length rules. This prevents bad inputs and returns clear 400 errors for short or long passwords.

  • Bug Fixes
    • Require non-empty userId and newPassword in the request body.
    • Enforce configured min/max password length; return 400 with PASSWORD_TOO_SHORT or PASSWORD_TOO_LONG.
    • Added tests for empty fields and length validation.

🔄 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/5075 **Author:** [@hieudien14310](https://github.com/hieudien14310) **Created:** 10/4/2025 **Status:** ✅ Merged **Merged:** 10/15/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `canary` ← **Head:** `fix/set-user-password` --- ### 📝 Commits (6) - [`9d68712`](https://github.com/better-auth/better-auth/commit/9d6871248b14dd9eb9a60861d493571046bb29b3) fix(admin): validate newPassword and userId fields for non-emptiness and enforce password length constraints - [`c6457ab`](https://github.com/better-auth/better-auth/commit/c6457ab802ca3256aa4b07c903dcfc7d55adfdf4) fix(admin): add tests - [`351f97a`](https://github.com/better-auth/better-auth/commit/351f97aeb8a33c7359552b94076239188ef6acbd) fix - [`3daf75d`](https://github.com/better-auth/better-auth/commit/3daf75dc1632a45427ba20890f91bd6644da65de) fix(admin): coerce userId to string and ensure non-emptiness validation - [`f2f8276`](https://github.com/better-auth/better-auth/commit/f2f8276796cc70246b6adde1c29b2f687bfe9092) Merge branch 'canary' into fix/set-user-password - [`c0647ba`](https://github.com/better-auth/better-auth/commit/c0647ba95e8eae58ce3cd5d1247f79e136f0f15f) Merge branch 'canary' into fix/set-user-password ### 📊 Changes **2 files changed** (+83 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/plugins/admin/admin.test.ts` (+56 -0) 📝 `packages/better-auth/src/plugins/admin/admin.ts` (+27 -8) </details> ### 📄 Description <!-- This is an auto-generated description by cubic. --> ## Summary by cubic Strengthened validation for admin.setUserPassword to reject empty fields and enforce password length rules. This prevents bad inputs and returns clear 400 errors for short or long passwords. - **Bug Fixes** - Require non-empty userId and newPassword in the request body. - Enforce configured min/max password length; return 400 with PASSWORD_TOO_SHORT or PASSWORD_TOO_LONG. - Added tests for empty fields and length validation. <!-- 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:34: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#5755