Problems, need help? Have a tip or advice? Post it here.
4 posts Page 1 of 1
Hello,

I succesfully set up the extended-users functionality according to the tutorial and tested its various functions and everything works. Except for one thing. I tried to add a validator for the password input while creating an account and seemingly the validator does nothing at all.

Code: Select all
 <cms:input name='extended_user_password' type='bound' required='1' validator='regex=/^(?=.+[A-Z])(?=.+[!@#$&*])(?=.+[0-9])(?=.+[a-z]).{16,}$/'/>


I tried adding it to the corresponding editable in extended-users.php as well, with the train of thought that the validator is maybe overwritten when the corresponding fields are pulled into the form, but that didn't work as well.

An account is created regardless of the conditions I set in the regex. The only condition which independently seems to be set is, that a password can't be less than 5 characters.

Any idea how I maybe could get the validator to work? Since without it passwords such as "111111" are possible.
Thanks in advance.
Hello,
I am sure a solution is about adding a separator parameter. Documentation somehow didn't stress its necessity for a single regex validator, but it wouldn't work without it (if I duly remember my similar trouble, solved by @KK).
For reference, you may study the way your inputted validator is used in php code of cms.
Hi,

Point to keep in mind about using type 'bound' inputs is that they are actually mere pointers to the real editable regions (that appear in the admin-panel). This means that any validation (or other parameters) that you might define with the 'bound' inputs would simply be ignored.

To solve your issue, we can instead use a regular <cms:input> for password and apply custom validation to it.
Then upon successful form submission, we can pass on the value contained in this input to the real region.

Please see the following thread for a complete example -
https://www.couchcms.com/forum/viewtopi ... 453#p20640

In the example above, we are using regular inputs for all the fields. For your use case you can do so for only the password field.

Related to what @trendoman mentioned - in case you have difficulty in using regex as a validator, you may define your own custom validator using plain PHP. Please see viewtopic.php?f=4&p=25456 for an example.

Hope it helps.
I've got it working now. Thank you to both of you.
4 posts Page 1 of 1
cron