Contao\CoreBundle\Security\ContaoAuthenticator::supportsToken PHP Method

supportsToken() public method

Checks if the token is supported.
public supportsToken ( Symfony\Component\Security\Core\Authentication\Token\TokenInterface $token, string $providerKey ) : boolean
$token Symfony\Component\Security\Core\Authentication\Token\TokenInterface
$providerKey string
return boolean
    public function supportsToken(TokenInterface $token, $providerKey)
    {
        return $token instanceof ContaoToken || $token instanceof AnonymousToken;
    }

Usage Example

 /**
  * Tests the token support.
  */
 public function testSupportsToken()
 {
     $authenticator = new ContaoAuthenticator();
     $this->assertTrue($authenticator->supportsToken(new ContaoToken($this->mockUser()), 'frontend'));
     $this->assertTrue($authenticator->supportsToken(new AnonymousToken('anon.', 'foo'), 'frontend'));
     $this->assertFalse($authenticator->supportsToken(new PreAuthenticatedToken('foo', 'bar', 'console'), 'console'));
 }