Esempio n. 1
0
 protected function getCreationEvent($formData)
 {
     $event = $this->createEventInstance($formData);
     // Create a secure password
     $event->setPassword(Password::generateRandom(8));
     // We will notify the customer of account creation
     $event->setNotifyCustomerOfAccountCreation(true);
     return $event;
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $login = $input->getArgument('login');
     if (null === ($admin = AdminQuery::create()->filterByLogin($login)->findOne())) {
         throw new \RuntimeException(sprintf('Admin with login %s does not exists', $login));
     }
     $password = $input->getOption('password') ?: Password::generateRandom();
     $event = new AdministratorUpdatePasswordEvent($admin);
     $event->setPassword($password);
     $this->getContainer()->get('event_dispatcher')->dispatch(TheliaEvents::ADMINISTRATOR_UPDATEPASSWORD, $event);
     $output->writeln(array('', sprintf('<info>admin %s password updated</info>', $login), sprintf('<info>new password is : %s</info>', $password), ''));
 }
Esempio n. 3
0
 private function generateSecureKey()
 {
     $fs = new Filesystem();
     $dir = $this->getKeyDir();
     if (!$fs->exists($dir)) {
         $fs->mkdir($dir, 0700);
     }
     $file = $dir . DS . $this->getApiKey() . ".key";
     $fs->touch($file);
     file_put_contents($file, Password::generateHexaRandom(45));
     $fs->chmod($file, 0600);
 }
Esempio n. 4
0
 public function lostPassword(LostPasswordEvent $event)
 {
     if (null !== ($customer = CustomerQuery::create()->filterByEmail($event->getEmail())->findOne())) {
         $password = Password::generateRandom(8);
         $customer->setPassword($password)->save();
         $this->mailer->sendEmailToCustomer('lost_password', $customer, ['password' => $password]);
     }
 }
Esempio n. 5
0
 public function testGenerateHexaRandom()
 {
     $length = 8;
     $password = Password::generateHexaRandom($length);
     $this->assertEquals($length, strlen($password));
 }