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...).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

frankcarey’s picture

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 :(

jgalletta’s picture

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.

jgalletta’s picture

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

erikwebb’s picture

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?

erikwebb’s picture

Status: Needs work » Needs review
FileSize
1.37 KB

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.

jgalletta’s picture

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
erikwebb’s picture

Status: Needs work » Needs review
FileSize
2.33 KB

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

erikwebb’s picture

Status: Fixed » Closed (fixed)

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