diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Entity/Registration.php b/src/ninegate-1.0/src/Cadoles/CoreBundle/Entity/Registration.php index 0fd438f7..9f2640d2 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Entity/Registration.php +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Entity/Registration.php @@ -6,8 +6,8 @@ use Doctrine\Common\Collections\ArrayCollection; use Symfony\Component\Security\Core\User\UserInterface; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; +use Cadoles\CoreBundle\Validator as CadolesCoreAssert; use Symfony\Component\Validator\Constraints as Assert; -use Cadoles\CoreBundle\Validator\Password; /** * @ORM\Entity @@ -51,6 +51,11 @@ class Registration implements UserInterface, \Serializable * @ORM\Column(type="string", length=250) */ private $password; + + /** + * @CadolesCoreAssert\Password() + */ + private $passwordplain; /** * @ORM\Column(type="string", length=250) @@ -184,7 +189,10 @@ class Registration implements UserInterface, \Serializable public function setPassword($password) { - if($password!=$this->password&&$password!=""){ + if($password!=$this->password&&$password!=""){ + // Placer le password non encodé dans une variable tempo sur laquel on va appliquer la contraite + $this->passwordplain = $password; + // Password encrypté format openldap mt_srand((double)microtime()*1000000); $this->salt = pack("CCCC", mt_rand(), mt_rand(), mt_rand(), mt_rand()); diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Entity/User.php b/src/ninegate-1.0/src/Cadoles/CoreBundle/Entity/User.php index 304ff36f..c2b826be 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Entity/User.php +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Entity/User.php @@ -10,6 +10,8 @@ use Cadoles\CoreBundle\Validator as CadolesCoreAssert; use Symfony\Component\Validator\Constraints as Assert; + + /** * @ORM\Entity * @ORM\Table(name="user") @@ -29,6 +31,12 @@ class User implements UserInterface, \Serializable /** * @ORM\Column(type="string", length=50, unique=true) + * @Assert\Length( + * min = "5", + * max = "25", + * minMessage = "Votre nom doit faire au moins {{ limit }} caractères", + * maxMessage = "Votre nom ne peut pas être plus long que {{ limit }} caractères" + * ) */ private $username; @@ -44,9 +52,13 @@ class User implements UserInterface, \Serializable /** * @ORM\Column(type="string", length=250) - * @CadolesCoreAssert\PasswordValidator */ private $password; + + /** + * @CadolesCoreAssert\Password() + */ + private $passwordplain; /** * @ORM\Column(type="string", length=250) @@ -393,6 +405,9 @@ class User implements UserInterface, \Serializable public function setPassword($password) { if($password!=$this->password&&$password!=""){ + // Placer le password non encodé dans une variable tempo sur laquel on va appliquer la contraite + $this->passwordplain = $password; + // Password encrypté format openldap mt_srand((double)microtime()*1000000); $this->salt = pack("CCCC", mt_rand(), mt_rand(), mt_rand(), mt_rand()); diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Validator/PasswordValidator.php b/src/ninegate-1.0/src/Cadoles/CoreBundle/Validator/PasswordValidator.php index 39f1487a..cf5f64fe 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Validator/PasswordValidator.php +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Validator/PasswordValidator.php @@ -11,8 +11,6 @@ class PasswordValidator extends ConstraintValidator { public function validate($value, Constraint $constraint) { - $this->context->addViolation($constraint->message); - if(!empty($value)) { if (strlen($value) < '8') { $this->context->addViolation($constraint->message);