Exemplo 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), ''));
 }
Exemplo n.º 3
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]);
     }
 }
Exemplo n.º 4
0
 public function testGenerateRandom()
 {
     $length = 8;
     $password = Password::generateRandom($length);
     $this->assertEquals($length, strlen($password));
 }