/**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $userId = $input->getArgument('userId');
     $user = $this->userManager->findUserBy(['id' => $userId]);
     if (!$user) {
         throw new \Exception("No user with id #{$userId} was found.");
     }
     $jwt = $this->jwtManager->createJwtFromUser($user, $input->getOption('ttl'));
     $output->writeln('Success!');
     $output->writeln('Token: ' . $jwt);
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $now = new DateTime();
     $userId = $input->getArgument('userId');
     $user = $this->userManager->findUserBy(['id' => $userId]);
     if (!$user) {
         throw new \Exception("No user with id #{$userId} was found.");
     }
     $authentication = $user->getAuthentication();
     if (!$authentication) {
         $authentication = $this->authenticationManager->createAuthentication();
         $authentication->setUser($user);
     }
     $authentication->setInvalidateTokenIssuedBefore($now);
     $this->authenticationManager->updateAuthentication($authentication);
     $output->writeln('Success!');
     $output->writeln('All the tokens for ' . $user->getFirstAndLastName() . ' issued before Today at ' . $now->format('g:i:s A e') . ' have been invalidated.');
 }
Beispiel #3
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $campusId = $input->getArgument('campusId');
     $user = $this->userManager->findUserBy(['campusId' => $campusId]);
     if ($user) {
         throw new \Exception('User #' . $user->getId() . " with campus id {$campusId} already exists.");
     }
     $schoolId = $input->getArgument('schoolId');
     $school = $this->schoolManager->findSchoolBy(['id' => $schoolId]);
     if (!$school) {
         throw new \Exception("School with id {$schoolId} could not be found.");
     }
     $userRecord = $this->directory->findByCampusId($campusId);
     if (!$userRecord) {
         $output->writeln("<error>Unable to find campus ID {$campusId} in the directory.</error>");
         return;
     }
     $table = new Table($output);
     $table->setHeaders(array('Campus ID', 'First', 'Last', 'Email', 'Username', 'Phone Number'))->setRows(array([$userRecord['campusId'], $userRecord['firstName'], $userRecord['lastName'], $userRecord['email'], $userRecord['username'], $userRecord['telephoneNumber']]));
     $table->render();
     $helper = $this->getHelper('question');
     $output->writeln('');
     $question = new ConfirmationQuestion("<question>Do you wish to add this user to Ilios?</question>\n", true);
     if ($helper->ask($input, $output, $question)) {
         $user = $this->userManager->createUser();
         $user->setFirstName($userRecord['firstName']);
         $user->setLastName($userRecord['lastName']);
         $user->setEmail($userRecord['email']);
         $user->setCampusId($userRecord['campusId']);
         $user->setAddedViaIlios(true);
         $user->setEnabled(true);
         $user->setSchool($school);
         $user->setUserSyncIgnore(false);
         $this->userManager->updateUser($user);
         $authentication = $this->authenticationManager->createAuthentication();
         $authentication->setUser($user);
         $authentication->setUsername($userRecord['username']);
         $this->authenticationManager->updateAuthentication($authentication);
         $output->writeln('<info>Success! New user #' . $user->getId() . ' ' . $user->getFirstAndLastName() . ' created.</info>');
     } else {
         $output->writeln('<comment>Canceled.</comment>');
     }
 }
Beispiel #4
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $userId = $input->getArgument('userId');
     $user = $this->userManager->findUserBy(['id' => $userId]);
     if (!$user) {
         throw new \Exception("No user with id #{$userId} was found.");
     }
     $userRecord = $this->directory->findByCampusId($user->getCampusId());
     if (!$userRecord) {
         $output->writeln('<error>Unable to find ' . $user->getCampusId() . ' in the directory.');
         return;
     }
     $table = new Table($output);
     $table->setHeaders(array('Record', 'Campus ID', 'First', 'Last', 'Email', 'Phone Number'))->setRows(array(['Ilios User', $user->getCampusId(), $user->getFirstName(), $user->getLastName(), $user->getEmail(), $user->getPhone()], ['Directory User', $userRecord['campusId'], $userRecord['firstName'], $userRecord['lastName'], $userRecord['email'], $userRecord['telephoneNumber']]));
     $table->render();
     $helper = $this->getHelper('question');
     $output->writeln('');
     $question = new ConfirmationQuestion('<question>Do you wish to update this Ilios User with the data ' . 'from the Directory User? </question>' . "\n", true);
     if ($helper->ask($input, $output, $question)) {
         $user->setFirstName($userRecord['firstName']);
         $user->setLastName($userRecord['lastName']);
         $user->setEmail($userRecord['email']);
         $user->setPhone($userRecord['telephoneNumber']);
         $authentication = $user->getAuthentication();
         if (!$authentication) {
             $authentication = $this->authenticationManager->createAuthentication();
             $authentication->setUser($user);
         }
         $authentication->setUsername($userRecord['username']);
         $this->authenticationManager->updateAuthentication($authentication, false);
         $this->userManager->updateUser($user);
         $output->writeln('<info>User updated successfully!</info>');
     } else {
         $output->writeln('<comment>Update canceled.</comment>');
     }
 }