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

createToken() public method

Creates an authentication token.
public createToken ( Request $request, string $providerKey ) : AnonymousToken
$request Symfony\Component\HttpFoundation\Request
$providerKey string
return Symfony\Component\Security\Core\Authentication\Token\AnonymousToken
    public function createToken(Request $request, $providerKey)
    {
        return new AnonymousToken($providerKey, 'anon.');
    }

Usage Example

 /**
  * Tests creating an authentication token.
  */
 public function testCreateToken()
 {
     $authenticator = new ContaoAuthenticator();
     $token = $authenticator->createToken(new Request(), 'frontend');
     $this->assertInstanceOf('Symfony\\Component\\Security\\Core\\Authentication\\Token\\AnonymousToken', $token);
     $this->assertEquals('frontend', $token->getSecret());
     $this->assertEquals('anon.', $token->getUsername());
 }