/**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $uid = $input->getArgument('uid');
     $account = User::load($uid);
     if (!$account) {
         // Error loading User entity.
         throw new \InvalidArgumentException(sprintf($this->trans('commands.user.login.clear.attempts.errors.invalid-user'), $uid));
     }
     // Define event name and identifier.
     $event = 'user.failed_login_user';
     // Identifier is created by uid and IP address,
     // Then we defined a generic identifier.
     $identifier = "{$account->id()}-";
     // Retrieve current database connection.
     $connection = $this->getDatabase();
     // Clear login attempts.
     $connection->delete('flood')->condition('event', $event)->condition('identifier', $connection->escapeLike($identifier) . '%', 'LIKE')->execute();
     // Command executed successful.
     $output->success(sprintf($this->trans('commands.user.login.clear.attempts.messages.successful'), $uid));
 }
Example #2
0
 /**
  * @param \Symfony\Component\Console\Output\OutputInterface $io
  * @param                                                   $key
  * @param                                                   $instance
  * Backup database
  */
 private function backupDatabase(OutputInterface $io, $key, $instance)
 {
     if (array_key_exists('database', $instance)) {
         $io->caution(sprintf('Database Backup %s', $key));
         $database = $instance['database'];
         $dbManager = new DatabaseManager($database['host'], $database['port'], $database['name'], $database['user'], $database['password']);
         $dbManager->setTemporaryDirectory($this->tmpTime);
         $dbManager->execute();
         $io->success(sprintf('Database Backup %s', $key));
     }
 }