/**
  * Ask for email authentication code.
  *
  * @param AuthenticationContextInterface $context
  *
  * @return Response|null
  */
 public function requestAuthenticationCode(AuthenticationContextInterface $context)
 {
     $user = $context->getUser();
     $request = $context->getRequest();
     $session = $context->getSession();
     // Display and process form
     $authCode = $request->get($this->authCodeParameter);
     if ($authCode !== null) {
         if ($this->authenticator->checkCode($user, $authCode)) {
             $context->setAuthenticated(true);
             return new RedirectResponse($request->getUri());
         }
         $session->getFlashBag()->set('two_factor', 'scheb_two_factor.code_invalid');
     }
     // Force authentication code dialog
     return $this->renderer->render($context);
 }
 /**
  * Ask for email authentication code
  *
  * @param  \Scheb\TwoFactorBundle\Security\TwoFactor\AuthenticationContext $context
  * @return \Symfony\Component\HttpFoundation\Response|null
  */
 public function requestAuthenticationCode(AuthenticationContext $context)
 {
     $user = $context->getUser();
     $request = $context->getRequest();
     $session = $context->getSession();
     // Display and process form
     $authCode = $request->get($this->authCodeParameter);
     if ($authCode !== null) {
         if ($this->authenticator->checkCode($user, $authCode)) {
             $context->setAuthenticated(true);
             return new RedirectResponse($request->getUri());
         } else {
             $session->getFlashBag()->set("two_factor", "scheb_two_factor.code_invalid");
         }
     }
     // Force authentication code dialog
     return $this->templating->renderResponse($this->formTemplate, array('useTrustedOption' => $context->useTrustedOption()));
 }