Пример #1
0
 /**
  * Before advice for all methods annotated with "@FLOW3\Session(autoStart=true)".
  * Those methods will trigger a session initialization if a session does not exist
  * yet.
  *
  * @param \TYPO3\FLOW3\Aop\JoinPointInterface $joinPoint The current join point
  * @return void
  * @fixme The pointcut expression below does not consider the options of the session annotation – needs adjustments in the AOP framework
  * @FLOW3\Before("methodAnnotatedWith(TYPO3\FLOW3\Annotations\Session)")
  */
 public function initializeSession(\TYPO3\FLOW3\Aop\JoinPointInterface $joinPoint)
 {
     if ($this->session->isStarted() === TRUE) {
         return;
     }
     $objectName = $this->objectManager->getObjectNameByClassName(get_class($joinPoint->getProxy()));
     $methodName = $joinPoint->getMethodName();
     $this->systemLogger->log(sprintf('Session initialization triggered by %s->%s.', $objectName, $methodName), LOG_DEBUG);
     $this->session->start();
 }
 /**
  * Checks if there exists a user session and if at least one token is authenticated
  *
  * @return boolean
  */
 public function isAuthenticated()
 {
     if (!$this->session->isStarted() && !$this->session->canBeResumed()) {
         return FALSE;
     }
     $atLeastOneTokenIsAuthenticated = FALSE;
     foreach ($this->securityContext->getAuthenticationTokens() as $token) {
         if ($token->isAuthenticated()) {
             $atLeastOneTokenIsAuthenticated = TRUE;
             break;
         }
     }
     return $atLeastOneTokenIsAuthenticated;
 }