From af5c6f96267f96101c6fbba28a76aeb7a8f187bd Mon Sep 17 00:00:00 2001 From: Arnaud Fornerot Date: Thu, 15 Sep 2022 14:54:34 +0200 Subject: [PATCH] =?UTF-8?q?renforcer=20par=20un=20uuid=20la=20g=C3=A9n?= =?UTF-8?q?=C3=A9ration=20auto=20d'un=20password?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Command/SynchroCommand.php | 14 +++++++++++--- src/Controller/SecurityController.php | 3 ++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/Command/SynchroCommand.php b/src/Command/SynchroCommand.php index a2fd0e9..389a303 100644 --- a/src/Command/SynchroCommand.php +++ b/src/Command/SynchroCommand.php @@ -280,9 +280,12 @@ class SynchroCommand extends Command $user->setUsername($ldapentry[$this->username]); $user->setIsvisible(true); $user->setApikey(Uuid::uuid4()); - $user->setPassword("LDAPPWD-".$ldapentry[$this->username]); $user->setRole("ROLE_USER"); $user->setAvatar("noavatar.png"); + + $uuid=Uuid::uuid4(); + $user->setPassword("PWD-".$ldapentry[$this->username]."-".$uuid); + $this->em->persist($user); } @@ -736,9 +739,12 @@ class SynchroCommand extends Command $user->setUsername($nineuser->userlogin); $user->setIsvisible(true); $user->setApikey(Uuid::uuid4()); - $user->setPassword("NINEPWD-".$nineuser->userlogin); $user->setRole("ROLE_USER"); $user->setAvatar($nineuser->useravatar); + + $uuid=Uuid::uuid4(); + $user->setPassword("PWD-".$nineuser->userlogin."-".$uuid); + $this->em->persist($user); } @@ -893,11 +899,13 @@ class SynchroCommand extends Command $user->setEmail($email); $user->setNiveau01($niveau01); $user->setSiren($niveau01->getSiren()); - $user->setPassword("PASSWORDFROMEXTERNE"); $user->setVisible(true); $user->setAuthlevel("simple"); $user->setBelongingpopulation("agent"); + $uuid=Uuid::uuid4(); + $user->setPassword("PWD-".$username."-".$uuid); + if(in_array($username,$usersadmin)) $user->setRole("ROLE_ADMIN"); else { diff --git a/src/Controller/SecurityController.php b/src/Controller/SecurityController.php index a350eb6..cfa2d13 100755 --- a/src/Controller/SecurityController.php +++ b/src/Controller/SecurityController.php @@ -457,7 +457,8 @@ class SecurityController extends AbstractController if(empty($avatar)) $avatar = "noavatar.png"; if(empty($firstname)) $firstname = " "; if(empty($lastname)) $lastname = $username; - $password=$this->getParameter("appAuth")."PWD-".$username; + $uuid=Uuid::uuid4(); + $password=$this->getParameter("appAuth")."PWD-".$username."-".$uuid; // Si aucun niveau01 on prend par défaut le niveau system if(!$niveau01) $niveau01=$em->getRepository('App\Entity\Niveau01')->find(-1);