Neos\Flow\Security\Authentication\AuthenticationProviderManager::logout PHP Метод

logout() публичный Метод

Logout all active authentication tokens
public logout ( ) : void
Результат void
    public function logout()
    {
        if ($this->isAuthenticated() !== true) {
            return;
        }
        $this->isAuthenticated = null;
        /** @var $token TokenInterface */
        foreach ($this->securityContext->getAuthenticationTokens() as $token) {
            $token->setAuthenticationStatus(TokenInterface::NO_CREDENTIALS_GIVEN);
        }
        $this->emitLoggedOut();
        if ($this->session->isStarted()) {
            $this->session->destroy('Logout through AuthenticationProviderManager');
        }
        $this->securityContext->refreshTokens();
    }

Usage Example

 /**
  * @test
  */
 public function logoutRefreshesTokensInSecurityContext()
 {
     $this->authenticationProviderManager = $this->getAccessibleMock(AuthenticationProviderManager::class, ['emitLoggedOut'], [], '', false);
     $this->inject($this->authenticationProviderManager, 'securityContext', $this->mockSecurityContext);
     $this->inject($this->authenticationProviderManager, 'session', $this->mockSession);
     $this->mockSession->expects($this->any())->method('canBeResumed')->will($this->returnValue(true));
     $this->mockSession->expects($this->any())->method('isStarted')->will($this->returnValue(true));
     $token = $this->getMockBuilder(TokenInterface::class)->disableOriginalConstructor()->getMock();
     $token->expects($this->any())->method('isAuthenticated')->will($this->returnValue(true));
     $this->mockSecurityContext->expects($this->any())->method('getAuthenticationTokens')->will($this->returnValue([$token]));
     $this->mockSecurityContext->expects($this->once())->method('refreshTokens');
     $this->authenticationProviderManager->logout();
 }