title: Authentication Failure Handler did not return a Response
body: <p>I have extended the  DefaultAuthenticationFailureHandler in order to redirect users to register page if the username is not in the database. it works fine for the first part.
  If the username exists in the database I want from the Controller the default behavior i.e. to redirect to the login page with the login error message. Why it is not issuing a redirect?</p>
  
  <pre><code>namespace UserBundle\Redirection;
  
  use Symfony\Component\Security\Core\SecurityContext;
  use Symfony\Component\DependencyInjection\ContainerInterface;
  use Symfony\Component\HttpFoundation\RedirectResponse;
  use Symfony\Component\HttpFoundation\Request;
  use Symfony\Component\HttpFoundation\Response;
  use Symfony\Component\Routing\RouterInterface;
  use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
  use Symfony\Component\Security\Core\Exception\AuthenticationException;
  use Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface;
  use Symfony\Component\Security\Http\Authentication\DefaultAuthenticationFailureHandler;
  use UserBundle\Controller\SecurityController;
  
  class AfterLoginFailureRedirection extends DefaultAuthenticationFailureHandler
  {
      /**
       * @var \Symfony\Component\Routing\RouterInterface
       */
      private $router;
      /**
       * @var \Symfony\Component\DependencyInjection\ContainerInterface
       */
      private $container;
  
  
  
      public function setRouter(RouterInterface $router)
      {
          $this-&gt;router = $router;
      }
  
      public function setContainer(ContainerInterface $container)
      {
          $this-&gt;container=$container;
  
      }
  
  
      /**
       * @param Request $request
       * @param AuthenticationException $token
       * @return RedirectResponse
       */
      public function onAuthenticationFailure(Request $request, AuthenticationException $exception)
      {
  
  
          //$request = $this-&gt;container-&gt;get('request');
          $token=$exception-&gt;getToken();
          $username=$token-&gt;getUsername();
          //$username = $request-&gt;request-&gt;get('email');
          $user = $this-&gt;container-&gt;get('fos_user.user_manager')-&gt;findUserByUsername($username);
  
          if(!$user) {
              $url=$this-&gt;container-&gt;get('router')-&gt;generate('fos_user_registration_register');
              return new RedirectResponse($url);
          }
          else
          {
              parent::onAuthenticationFailure($request,$exception);
          }
  }}
  </code></pre>