The configuration option for username constraint is not taken in account when the constraints are tested, so the validation (both php and javascript) is always executed.

After some debug, the problem is that the configuration is simply not tested in the validation functions (see constraint_username.inc, functions password_policy_constraint_username_validate() and password_policy_constraint_username_js(), the $constraint parameter is never used...).

Files: 
CommentFileSizeAuthor
#8 password_policy-username_constraint_always_tested-1226418-8.patch2.33 KBerikwebb
PASSED: [[SimpleTest]]: [MySQL] 334 pass(es).
[ View ]
#5 password_policy-username_constraint_always_tested-1226418-5.patch1.37 KBerikwebb
FAILED: [[SimpleTest]]: [MySQL] 333 pass(es), 1 fail(s), and 0 exception(s).
[ View ]
#1 check_name_constraint-1226418-1.patch625 bytesfrankcarey
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch check_name_constraint-1226418-1.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

Comments

StatusFileSize
new625 bytes
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch check_name_constraint-1226418-1.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

Yeah, just needed to actually check if the contraint is true (or evaluates to true). This should work, but I don't have time to test it. It is patched against my other patch that provides the ability to check names of new users, so you will have to apply that first. See http://drupal.org/node/1226434#comment-4770124

Man, 3 patches for me to get this working :(

Your patch works fine for the server side validation, but you forgot to also patch the javascript part :)
The same if with a return ''; if !$constraint in the js validation function should be fine.

The server side validation patch works fine for me, now need a patch for client-side validation.

Version:6.x-1.0-beta1» 6.x-1.x-dev
Status:Active» Needs work

Agreed, the patch in #1 looks like a win for the server-side. Any attempts on the JS side?

Status:Needs work» Needs review
StatusFileSize
new1.37 KB
FAILED: [[SimpleTest]]: [MySQL] 333 pass(es), 1 fail(s), and 0 exception(s).
[ View ]

Actually, I just tried to reproduce the problem and wasn't able to. I add a new policy, set username to '1', receive the error. Then erase the username value, then the error goes away.

I've attached a patch that should fix this problem, but I'm not really able to see what the problem is at the moment.

Status:Needs review» Reviewed & tested by the community

Works for me, I wrote the same code a while back and it's working on live site since this time.

Status:Reviewed & tested by the community» Needs work

The last submitted patch, password_policy-username_constraint_always_tested-1226418-5.patch, failed testing.

Status:Needs work» Needs review
StatusFileSize
new2.33 KB
PASSED: [[SimpleTest]]: [MySQL] 334 pass(es).
[ View ]

I introduced a bug with that patch actually. The test itself was also broken. Re-running the tests with a new patch.

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.