Repository navigation
Commit 5d7ada3
docs(auth): send newPassword in the reset-password example (#30112)
<!-- claude-projects-attribution: {"github_login":"marchtian"} -->
_Requested by **田騏** · [project
thread](https://claude.ai/code/project/chan_01VmuUhXU9SSUzqJYyXSmYSi?thread=cmsg_01VmuUhXU9SSUzqJYyXSmYSiNjyvCdXYygFqntMNR7S2dW)_
Fixes #29852
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:认证文档「Reset Password with Token」示例的请求体字段从 `password` 改为
`newPassword`,仅此一行。
- 为什么改:重置密码接口要求 `newPassword`,照文档复制的请求会被 400
拒绝,用户无法完成密码重置;同页其余重置/验证示例已逐一对照接口校验,均正确。
- 风险与回滚:纯文档改动,不触任何运行时代码与发布包;回滚即还原这一行。
- 先看:`content/docs/permissions/authentication.mdx` 第 305 行(唯一改动)。
- 两分钟验证:`grep -n "newPassword: 'newSecurePassword456'"
content/docs/permissions/authentication.mdx`,应看到第 305 行一条命中。
- 需要你做的:无,席位落地。
## What changes
`content/docs/permissions/authentication.mdx`, "Reset Password with
Token": the body sent to `POST /api/v1/auth/reset-password` now carries
`newPassword` instead of `password`. The door's body schema is
better-auth 1.7.12 `resetPassword` (`dist/api/routes/password.mjs`):
`newPassword: z.string()` required, `token: z.string().optional()`. Sent
as previously documented the door answers `400 VALIDATION_ERROR`
(`[body.newPassword] ... received undefined`).
The other reset and verification examples on the page were each checked
against the body or query schema their door actually parses (installed
better-auth 1.7.12, plus this repo's `packages/plugins/plugin-auth`
mounts where one fronts the door). All match, so none changed:
| Example | Door schema read | Verdict |
|:---|:---|:---|
| Request Password Reset `{ email }` | better-auth
`requestPasswordReset`: `email` required, `redirectTo` optional |
matches |
| Reset Password with Token | better-auth `resetPassword`: `newPassword`
required, `token` optional | **fixed** (`password` → `newPassword`) |
| Setting a first local password `{ newPassword }` |
`plugin-auth/src/set-initial-password.ts`: reads `newPassword` | matches
|
| Send Verification Email (no body, bearer) | better-auth requires
`email`, but `plugin-auth/src/send-verification-email.ts` (mounted in
`auth-plugin.ts`) defaults it to the signed-in caller's email | matches
|
| Verify Email `?token=` | better-auth `verifyEmail` query: `token`
required, `callbackURL` optional | matches |
| Phone `send-otp` `{ phoneNumber }` | `phone-number/routes.mjs`
`sendPhoneNumberOTPBodySchema` | matches |
| Phone `verify` `{ phoneNumber, code }` | `verifyPhoneNumberBodySchema`
| matches |
| Phone `request-password-reset` `{ phoneNumber }` |
`requestPasswordResetPhoneNumberBodySchema` | matches |
| Phone `reset-password` `{ phoneNumber, otp, newPassword }` |
`resetPasswordPhoneNumberBodySchema` | matches |
| 2FA `verify-totp` `{ code }` | `two-factor/totp/index.mjs`
`verifyTOTPBodySchema`: `code` required, `trustDevice` optional |
matches |
| Magic link `verify?token=` | `magic-link/index.mjs`
`magicLinkVerifyQuerySchema`: `token` required | matches |
## Tests
Docs only. No test pins this example: the block's `os:check` marker
makes `check:skill-examples` type-check it with `tsc`, and
`JSON.stringify` takes any object, so that gate cannot see a wrong field
name. It still type-checks after the change.
## Acceptance notes
- The `os:check` gate proves a marked fetch example compiles, not that
its body matches the door. Noted, not filed.
## Verification
Gate readings are in the `os-dev-report` comment on #29852 (derived by
`scripts/pm/dispatch-gates.mjs --commands`, every exit code captured
before any pipe).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude <noreply@anthropic.com>1 parent 28ce3d1 commit 5d7ada3
1 file changed
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
302 | 302 | | |
303 | 303 | | |
304 | 304 | | |
305 | | - | |
| 305 | + | |
306 | 306 | | |
307 | 307 | | |
308 | 308 | | |
| |||
0 commit comments