예제 #1
0
 /**
  * @param Typo3OrgSsoToken $authenticationToken
  * @return bool
  */
 public function authenticate(Typo3OrgSsoToken $authenticationToken)
 {
     /** @var $account FrontendUser */
     $account = null;
     $credentials = $authenticationToken->getCredentials();
     if (is_array($credentials) && isset($credentials['username'])) {
         $account = $this->frontendUserRepository->findOneByUsername($credentials['username']);
     }
     $authenticated = false;
     $authenticationData = 'version=' . $credentials['version'] . '&user='******'username'] . '&tpa_id=' . $credentials['tpaId'] . '&expires=' . $credentials['expires'] . '&action=' . $credentials['action'] . '&flags=' . $credentials['flags'] . '&userdata=' . $credentials['userdata'];
     $authenticationDataIsValid = $this->verifySignature($authenticationData, $credentials['signature']);
     if ($authenticationDataIsValid && $credentials['expires'] > time()) {
         $userdata = $this->parseUserdata($credentials['userdata']);
         if (!is_object($account)) {
             $account = $this->createAccount($userdata);
             $this->frontendUserRepository->add($account);
         } elseif (is_object($account)) {
             $account = $this->updateAccount($account, $userdata);
             $this->frontendUserRepository->update($account);
         }
         $this->persistenceManager->persistAll();
         $this->authenticationService->registerSession($account);
         $authenticated = true;
     }
     return $authenticated;
 }
 /**
  * @param AbstractSession $session
  * @validate $session \TYPO3\Sessions\Domain\Validator\ActiveUserValidator
  * @return string
  */
 public function createAction(AbstractSession $session)
 {
     $user = $this->frontendUserRepository->findCurrentUser();
     $session->addSpeaker($user);
     $this->sessionRepository->add($session);
     $this->persistenceManager->persistAll();
     return json_encode($session);
 }
예제 #3
0
 /**
  * @param AbstractSession $session
  * @return string
  */
 public function deleteAction(AbstractSession $session)
 {
     $user = $this->frontendUserRepository->findCurrentUser();
     $vote = $this->voteRepository->findOneByUserAndSession($user, $session);
     if ($vote) {
         $this->voteRepository->remove($vote);
         $this->persistenceManager->persistAll();
     }
     return json_encode(true);
 }
예제 #4
0
 /**
  * @param AbstractSession $value
  * @return boolean
  */
 protected function isValid($value)
 {
     $user = $this->frontendUserRepository->findCurrentUser();
     if ($user !== null && $user !== $value->getSpeakers()->getPosition(0)) {
         $error = new \TYPO3\CMS\Extbase\Error\Error($this->translateErrorMessage('validator.sessionOwner', 'sessions'), 1452072731);
         $this->result->addError($error);
         return false;
     }
     return true;
 }
 public function meAction()
 {
     $user = $this->frontendUserRepository->findCurrentUser();
     if ($user !== null) {
         $this->view->assign('value', $user);
     } else {
         $this->response->setStatus(401);
         $uri = $this->uriBuilder->reset()->setTargetPageType('1450887489')->setCreateAbsoluteUri(true)->uriFor('login');
         $this->view->assign('value', ['loginUrl' => $uri]);
     }
 }