getAuthenticationStatus() === TokenInterface::AUTHENTICATION_SUCCESSFUL) { return; } // Force set isAuthenticated to true on authentication manager to update roles needed for entity privileges ObjectAccess::setProperty($this->authenticationManager, 'isAuthenticated', true, true); $domain = $this->domainRepository->findOneByActiveRequest(); if (!$domain) { if (!array_key_exists('Neos.Neos:Administrator', $this->securityContext->getRoles())) { $this->rollback($authenticationToken); } return; } // Check if user can access site and ensure it's not already loaded $this->entityManager->clear('TYPO3\Neos\Domain\Model\Site'); $site = $this->siteRepository->findByIdentifier(ObjectAccess::getProperty($domain->getSite(), 'Persistence_Object_Identifier', true)); if (!$site) { $this->rollback($authenticationToken); } } /** * @param TokenInterface $authenticationToken * @return void */ protected function rollback(TokenInterface $authenticationToken) { $authenticationToken->setAuthenticationStatus(TokenInterface::WRONG_CREDENTIALS); ObjectAccess::setProperty($this->authenticationManager, 'isAuthenticated', false, true); $this->policyService->reset(); $this->securityContext->refreshRoles(); } }