Reputation: 1469
I want to change the password pattern of FosUser Bundle.. (lets say, i will require the password to be minumum of 6 characters which also require 1 letter and 1 number. Where do i set this?
Upvotes: 1
Views: 932
Reputation: 91
I've add into User entity
// src/Acme/AcmeBundle/Entity/User.php
....
class User extends BaseUser{
....
/**
* @Assert\NotBlank(message="fos_user.username.blank", groups={"Registration", "Profile"})
* @Assert\Length(min=5, max="255",
* minMessage="fos_user.username.short", maxMessage="fos_user.username.long",
* groups={"Registration", "Profile"})
*/
protected $username;
/**
* @Assert\NotBlank(message="fos_user.password.blank", groups={"Registration", "ResetPassword", "ChangePassword"})
* @Assert\Length(min=6,
* minMessage="fos_user.password.short",
* groups={"Registration", "Profile", "ResetPassword", "ChangePassword"})
*/
protected $plainPassword;
Upvotes: 1
Reputation: 29932
Yuo can do this in FosUserBundle validator.
Take a look at this file:
/vendor/friendsofsymfony/user-bundle/FOS/UserBundle/Resources/config/validation.xml
Particularly:
<property name="plainPassword">
<constraint name="NotBlank">
<option name="message">fos_user.password.blank</option>
<option name="groups">Registration</option>
</constraint>
<constraint name="MinLength">
<option name="limit">2</option>
<option name="message">fos_user.password.short</option>
<option name="groups">
<value>Registration</value>
<value>Profile</value>
</option>
</constraint>
</property>
I don't know (but I suppose that I'm right) if exists a constraint of type "1 letter and 1 number".
In that case, you have to "build" it yourself and use in the same way you use the NotBlank
and MinLenght
constraint of this example
Upvotes: 2