Scheb\TwoFactorBundle\Security\TwoFactor\Session\SessionFlagManager::setComplete PHP Method

setComplete() public method

Set session flag completed.
public setComplete ( string $provider, Symfony\Component\Security\Core\Authentication\Token\TokenInterface $token )
$provider string
$token Symfony\Component\Security\Core\Authentication\Token\TokenInterface
    public function setComplete($provider, $token)
    {
        $sessionFlag = $this->getSessionFlag($provider, $token);
        return $this->session->set($sessionFlag, true);
    }

Usage Example

 /**
  * Iterate over two-factor providers and ask for two-factor authentication.
  * Each provider can return a response. The first response will be returned.
  *
  * @param AuthenticationContextInterface $context
  *
  * @return Response|null
  */
 public function requestAuthenticationCode(AuthenticationContextInterface $context)
 {
     $token = $context->getToken();
     // Iterate over two-factor providers and ask for completion
     /** @var TwoFactorProviderInterface $provider */
     foreach ($this->providers as $providerName => $provider) {
         if ($this->flagManager->isNotAuthenticated($providerName, $token)) {
             $response = $provider->requestAuthenticationCode($context);
             // Set authentication completed
             if ($context->isAuthenticated()) {
                 $this->eventDispatcher->dispatch(TwoFactorAuthenticationEvents::SUCCESS, new TwoFactorAuthenticationEvent());
                 $this->flagManager->setComplete($providerName, $token);
             } else {
                 if ($context->getRequest()->get($this->authRequestParameter) !== null) {
                     $this->eventDispatcher->dispatch(TwoFactorAuthenticationEvents::FAILURE, new TwoFactorAuthenticationEvent());
                 }
             }
             // Return response
             if ($response instanceof Response) {
                 return $response;
             }
         }
     }
     return null;
 }
All Usage Examples Of Scheb\TwoFactorBundle\Security\TwoFactor\Session\SessionFlagManager::setComplete