Scheb\TwoFactorBundle\Security\TwoFactor\Provider\TwoFactorProviderRegistry::beginAuthentication PHP Метод

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

Iterate over two-factor providers and begin the two-factor authentication process.
public beginAuthentication ( Scheb\TwoFactorBundle\Security\TwoFactor\AuthenticationContextInterface $context )
$context Scheb\TwoFactorBundle\Security\TwoFactor\AuthenticationContextInterface
    public function beginAuthentication(AuthenticationContextInterface $context)
    {
        /** @var TwoFactorProviderInterface $provider */
        foreach ($this->providers as $providerName => $provider) {
            if ($provider->beginAuthentication($context)) {
                $this->flagManager->setBegin($providerName, $context->getToken());
            }
        }
    }

Usage Example

 /**
  * @test
  */
 public function beginAuthentication_authenticationNotStarted_notSetSessionFlag()
 {
     $token = $this->getToken();
     $context = $this->getAuthenticationContext($token);
     //Stub the provider
     $this->provider->expects($this->any())->method("beginAuthentication")->will($this->returnValue(false));
     //Mock the SessionFlagManager
     $this->flagManager->expects($this->never())->method("setBegin");
     $this->registry->beginAuthentication($context);
 }