From d07acd733e91f2b31b4d6ebbbb7dde9c2e8ea239 Mon Sep 17 00:00:00 2001 From: afornerot Date: Fri, 19 Apr 2019 13:50:17 +0200 Subject: [PATCH] ajout commande pour forcer le password --- .../CoreBundle/Command/SetPasswordCommand.php | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 src/ninegate-1.0/src/Cadoles/CoreBundle/Command/SetPasswordCommand.php diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Command/SetPasswordCommand.php b/src/ninegate-1.0/src/Cadoles/CoreBundle/Command/SetPasswordCommand.php new file mode 100644 index 00000000..30814e7a --- /dev/null +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Command/SetPasswordCommand.php @@ -0,0 +1,78 @@ +setName('Core:SetPassword') + ->setDescription('Synchronisation Annuaire') + ->setHelp('This command Synchro for Core') + ->addArgument('username', InputArgument::OPTIONAL, 'username') + ->addArgument('password', InputArgument::OPTIONAL, 'password') + ; + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $this->container = $this->getApplication()->getKernel()->getContainer(); + $this->em = $this->container->get('doctrine')->getEntityManager(); + $this->output = $output; + $this->filesystem = new Filesystem(); + $this->rootlog = $this->container->get('kernel')->getRootDir()."/../var/logs/"; + + $this->writelnred(''); + $this->writelnred('== Core:SetPasword'); + $this->writelnred('=========================================================================================================='); + + $username = $input->getArgument('username'); + $this->writeln($username); + + $password = $input->getArgument('password'); + $this->writeln($password); + + $user = $this->em->getRepository('CadolesCoreBundle:User')->findOneBy(array('username' => $username)); + if($user) { + $user->setPassword($password); + $this->em->persist($user); + $this->em->flush(); + } + + $this->writeln(''); + return 1; + } + + private function writelnred($string) { + $this->output->writeln(''.$string.''); + $this->filesystem->appendToFile($this->rootlog.'cron.log', $string."\n"); + } + private function writeln($string) { + $this->output->writeln($string); + $this->filesystem->appendToFile($this->rootlog.'cron.log', $string."\n"); + } + + + +}