controle cohérance pwd
This commit is contained in:
parent
7c26cdb57f
commit
b8ee13c49b
|
@ -6,8 +6,8 @@ use Doctrine\Common\Collections\ArrayCollection;
|
||||||
|
|
||||||
use Symfony\Component\Security\Core\User\UserInterface;
|
use Symfony\Component\Security\Core\User\UserInterface;
|
||||||
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
||||||
|
use Cadoles\CoreBundle\Validator as CadolesCoreAssert;
|
||||||
use Symfony\Component\Validator\Constraints as Assert;
|
use Symfony\Component\Validator\Constraints as Assert;
|
||||||
use Cadoles\CoreBundle\Validator\Password;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Entity
|
* @ORM\Entity
|
||||||
|
@ -52,6 +52,11 @@ class Registration implements UserInterface, \Serializable
|
||||||
*/
|
*/
|
||||||
private $password;
|
private $password;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @CadolesCoreAssert\Password()
|
||||||
|
*/
|
||||||
|
private $passwordplain;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(type="string", length=250)
|
* @ORM\Column(type="string", length=250)
|
||||||
*/
|
*/
|
||||||
|
@ -185,6 +190,9 @@ class Registration implements UserInterface, \Serializable
|
||||||
public function setPassword($password)
|
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
|
// Password encrypté format openldap
|
||||||
mt_srand((double)microtime()*1000000);
|
mt_srand((double)microtime()*1000000);
|
||||||
$this->salt = pack("CCCC", mt_rand(), mt_rand(), mt_rand(), mt_rand());
|
$this->salt = pack("CCCC", mt_rand(), mt_rand(), mt_rand(), mt_rand());
|
||||||
|
|
|
@ -10,6 +10,8 @@ use Cadoles\CoreBundle\Validator as CadolesCoreAssert;
|
||||||
use Symfony\Component\Validator\Constraints as Assert;
|
use Symfony\Component\Validator\Constraints as Assert;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Entity
|
* @ORM\Entity
|
||||||
* @ORM\Table(name="user")
|
* @ORM\Table(name="user")
|
||||||
|
@ -29,6 +31,12 @@ class User implements UserInterface, \Serializable
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(type="string", length=50, unique=true)
|
* @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;
|
private $username;
|
||||||
|
|
||||||
|
@ -44,10 +52,14 @@ class User implements UserInterface, \Serializable
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(type="string", length=250)
|
* @ORM\Column(type="string", length=250)
|
||||||
* @CadolesCoreAssert\PasswordValidator
|
|
||||||
*/
|
*/
|
||||||
private $password;
|
private $password;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @CadolesCoreAssert\Password()
|
||||||
|
*/
|
||||||
|
private $passwordplain;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(type="string", length=250)
|
* @ORM\Column(type="string", length=250)
|
||||||
*/
|
*/
|
||||||
|
@ -393,6 +405,9 @@ class User implements UserInterface, \Serializable
|
||||||
public function setPassword($password)
|
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
|
// Password encrypté format openldap
|
||||||
mt_srand((double)microtime()*1000000);
|
mt_srand((double)microtime()*1000000);
|
||||||
$this->salt = pack("CCCC", mt_rand(), mt_rand(), mt_rand(), mt_rand());
|
$this->salt = pack("CCCC", mt_rand(), mt_rand(), mt_rand(), mt_rand());
|
||||||
|
|
|
@ -11,8 +11,6 @@ class PasswordValidator extends ConstraintValidator
|
||||||
{
|
{
|
||||||
public function validate($value, Constraint $constraint)
|
public function validate($value, Constraint $constraint)
|
||||||
{
|
{
|
||||||
$this->context->addViolation($constraint->message);
|
|
||||||
|
|
||||||
if(!empty($value)) {
|
if(!empty($value)) {
|
||||||
if (strlen($value) < '8') {
|
if (strlen($value) < '8') {
|
||||||
$this->context->addViolation($constraint->message);
|
$this->context->addViolation($constraint->message);
|
||||||
|
|
Loading…
Reference in New Issue