fix(forms): clamp password minimum length to 6#3187
Open
faisalahammad wants to merge 1 commit into
Open
Conversation
The password field allowed admins to set a minimum length below the absolute floor of 6. When saved, the password strength meter and server validation still rejected passwords under 6 characters, creating a confusing mismatch between the UI setting and actual behavior. - Clamp minlength to 6 in the form validator. - Clamp the dynamic strength meter's min_length to 6. - Update existing tests to expect the 6-character floor and add a new test for the clamping behavior. Fixes gocodebox#3045
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Issue #3045 reported that the password field minimum length could be set to a value lower than 6, which left users unable to submit a password because the strength meter and validator still enforce a 6-character floor. This change clamps the configured minimum length to 6 everywhere it is read so the UI and backend agree.
Fixes #3045
Changes
includes/forms/class-llms-form-validator.phpBefore:
After:
Why: The server-side validator now enforces the same absolute minimum as the strength meter, so a saved value below 6 cannot produce a mismatch.
includes/forms/class-llms-forms-dynamic-fields.phpBefore:
After:
Why: The dynamic strength meter block reads the raw block attribute. Clamping it here keeps the meter in sync with the validator.
tests/phpunit/unit-tests/forms/class-llms-test-form-validator.phpUpdated the existing
minlengthtest to expect the 6-character floor, and addedtest_validate_field_attribute_minlength_clamps_to_six()to verify a configuredminlengthof 1 is treated as 6.Testing
Test 1: Manual form validation
Result: Works as expected.