symfony2 - Extending FOSUserBundle password validation to require special characters -



symfony2 - Extending FOSUserBundle password validation to require special characters -

i using fosuserbundle. have implemented own user entity additional class variables. registration, login, , lost password working expected. :-)

i need add together additional requirements password validation. found symfony article in the symfony docs. article explains how create validation method , reference in validation.xml file callback constraint. have implemented callback , changed validation.xml , working fine registration.

what haven't figured out how working password changes via lost password link or alter password page.

advice , documentation pointers welcome.

thanks in advance.

okay. turns out needed create validate.xml file user bundle , utilize grouping names different used fosuserbundle. needed update config.yml specify groups. specifically, modified config.yml thusly:

fos_user: ... change_password: form: validation_groups: [mychangepassword]

and in src/myproject/userbundle/resources/config/validation.xml:

<constraint-mapping xmlns="http://symfony.com/schema/dic/constraint-mapping" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd"> <!-- ! password constraints: !--> <class name="fos\userbundle\form\model\changepassword"> <property name="new"> <constraint name="regex"> <option name="pattern">/[0-9!@#$%^*_-]+/</option> <option name="message">must include @ to the lowest degree 1 digit or !,@,#,$,%,^,*</option> <option name="groups"> <value>mychangepassword</value> </option> </constraint> <constraint name="length"> <option name="min">8</option> <option name="max">254</option> <option name="minmessage">must @ to the lowest degree 8 characters</option> <option name="maxmessage">too long</option> <option name="groups"> <value>mychangepassword</value> </option> </constraint> </property> </class> </constraint-mapping>

hope save else time.

symfony2 fosuserbundle

Comments

Popular posts from this blog

c - Compilation of a code: unkown type name string -

java - Bypassing "final local variable defined in an enclosing type" -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -