Esempio n. 1
0
 /**
  *
  *
  * @return string
  */
 public function indexAction()
 {
     \Admin\Core\API::addTitleSegment("Admin");
     \Admin\Core\API::addTitleSegment("Login");
     $users = $this->userRepository->findAll();
     if ($users->count() < 1 || $this->helper->getSettings("Admin.DemoMode")) {
         $user = $this->objectManager->get("Admin\\Security\\User");
         $username = "******";
         if ($users->count() > 0) {
             $username .= $users->count() + 1;
         }
         $user->setAccountIdentifier($username);
         $user->setCredentialsSource("password");
         $user->setAdmin(true);
         $this->userRepository->add($user);
         $message = new \TYPO3\FLOW3\Error\Message('A User has been Created: ' . $username . '/password');
         $this->flashMessageContainer->addMessage($message);
         $message = new \TYPO3\FLOW3\Error\Warning('Please Change the Passwort after Login!');
         $this->flashMessageContainer->addMessage($message);
         $this->view->assign("username", $username);
         $this->view->assign("password", "password");
     } else {
         $this->view->assign("username", "");
         $this->view->assign("password", "");
     }
 }
Esempio n. 2
0
 /**
  * Sets isAuthenticated to TRUE for all tokens.
  *
  * @param TYPO3\FLOW3\Security\Authentication\TokenInterface $authenticationToken The token to be authenticated
  * @return void
  * @author Andreas Förthner <*****@*****.**>
  */
 public function authenticate(\TYPO3\FLOW3\Security\Authentication\TokenInterface $authenticationToken)
 {
     if (!$authenticationToken instanceof \Admin\Security\Token\UsernamePassword) {
         throw new \TYPO3\FLOW3\Security\Exception\UnsupportedAuthenticationTokenException('This provider cannot authenticate the given token.', 1217339840);
     }
     $user = NULL;
     $credentials = $authenticationToken->getCredentials();
     if (is_array($credentials) && isset($credentials['username'])) {
         $user = $this->userRepository->findByAccountIdentifierAndAuthenticationProviderName($credentials['username'], $this->name);
     }
     if (is_object($user)) {
         if ($this->hashService->validateSaltedMd5($credentials['password'], $user->getCredentialsSource())) {
             $authenticationToken->setAuthenticationStatus(\TYPO3\FLOW3\Security\Authentication\TokenInterface::AUTHENTICATION_SUCCESSFUL);
             $authenticationToken->setUser($user);
         } else {
             $authenticationToken->setAuthenticationStatus(\TYPO3\FLOW3\Security\Authentication\TokenInterface::WRONG_CREDENTIALS);
         }
     } elseif ($authenticationToken->getAuthenticationStatus() !== \TYPO3\FLOW3\Security\Authentication\TokenInterface::AUTHENTICATION_SUCCESSFUL) {
         $authenticationToken->setAuthenticationStatus(\TYPO3\FLOW3\Security\Authentication\TokenInterface::NO_CREDENTIALS_GIVEN);
     }
 }