You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix: run the password field's validation on reset password - #19006
Reset password now runs the collection's password field validation, the same as create and update do. Before this change, a password field override (such as minLength: 8 or a custom validate) did not apply to resets, so a user could reset their password to abc.
This is the preferred solution over #18826. That PR only passes minLength/maxLength through to the hardcoded validator, so a custom validate on the password field is still skipped. This change runs the field's own validate function, which covers both.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
📝 Walkthrough
Password resets now validate submitted passwords against the collection’s configured password field before hashing. Integration tests cover minimum-length and custom validation, including rejected and accepted passwords.
Changes: Password reset validation
Layer / File(s)
Summary
Run the password field validator before hashing packages/payload/src/auth/operations/resetPassword.ts
The reset operation calls the collection password field validator after finding a valid, unexpired reset token and before hashing. If no validator exists, validation is skipped. A string result raises a ValidationError at the password path.
Configure and test password validation test/auth/config.ts, test/auth/shared.ts, test/auth/int.spec.ts
Auth test collections configure minimum-length and custom password validation. Integration tests verify that invalid reset passwords are rejected and that a password meeting the minimum length is accepted.
The supplied changes and tests show the intended password-reset validation behavior, with no established issue requiring a fix before merge.
Security architecture risk:🔵 Low · up to ac8ce
The change strengthens password-policy enforcement while preserving reset-token authorization. No newly introduced attack path was established. Remaining uncertainty concerns context-dependent custom validators and transaction failure handling.
Retained concerns
No architecture-level concerns identified.
Security review details
Security Blast Radius
inferred — The change affects authentication collections using this reset operation and their configured password validators. Per request, the collection-scoped reset token selects the target account before the submitted password reaches the callback; the change does not establish broader account-selection authority.
Trust Boundaries and Controls
observed — The validator receives the token-selected account through id, data, and siblingData, while req retains the incoming caller identity. The operation assigns the authenticated reset user to req.user only later, after successful credential processing and JWT creation.
Resilience and Maintainability Implications
inferred — Validation rejection adds another route to the existing unconditional transaction cleanup. That cleanup can affect a transaction supplied by a local caller, but invalid-token failures already reached it before this PR; no increased attacker authority was established. GraphQL isolates the transactionID property. Caller-owned transaction recovery remains a limitation of this assessment.
Pre-merge checks: 5
Check name
Status
Explanation
Title check
The title clearly identifies the main change: running password field validation during password reset.
Description check
The description directly explains the password reset validation fix, its purpose, implementation choice, and related issue.
Linked Issues check
Issue #18823 is closed and completed, so it supplies historical context only. No active directly linked issue supplies coding requirements for this pull request.
Out of Scope Changes check
The changes remain within the stated password-reset fix. resetPassword.ts validates the collection password field before hashing and updating. The auth configuration and integration tests cover `min…
Docstring Coverage
Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 4 files.
Full details: Out of Scope Changes check
Explanation
The changes remain within the stated password-reset fix. resetPassword.ts validates the collection password field before hashing and updating. The auth configuration and integration tests cover minLength and custom validation behavior.
✨ Finishing Touches
📝 Generate docstrings
Commit to this branch
Create a new PR
🧪 Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment @coderabbitai help to get the list of available commands.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Same fix as #18980 (3.x), ported to
main.Reset password now runs the collection's
passwordfield validation, the same as create and update do. Before this change, apasswordfield override (such asminLength: 8or a customvalidate) did not apply to resets, so a user could reset their password toabc.This is the preferred solution over #18826. That PR only passes
minLength/maxLengththrough to the hardcoded validator, so a customvalidateon thepasswordfield is still skipped. This change runs the field's ownvalidatefunction, which covers both.Fixes #18823