/** * Iterate over two-factor providers and ask for two-factor authentcation. * Each provider can return a response. The first response will be returned. * * @param \Scheb\TwoFactorBundle\Security\TwoFactor\AuthenticationContext $context * @return \Symfony\Component\HttpFoundation\Response|null */ public function requestAuthenticationCode(AuthenticationContext $context) { $token = $context->getToken(); // Iterate over two-factor providers and ask for completion foreach ($this->providers as $providerName => $provider) { if ($this->flagManager->isNotAuthenticated($providerName, $token)) { $response = $provider->requestAuthenticationCode($context); // Set authentication completed if ($context->isAuthenticated()) { $this->flagManager->setComplete($providerName, $token); } // Return response if ($response instanceof Response) { return $response; } } } return null; }
/** * @test */ public function getToken_objectInitialized_returnToken() { $returnValue = $this->authContext->getToken(); $this->assertEquals($this->token, $returnValue); }