title: Success handler not working after Symfony2 login
body: <p>The goal is to do something after authentication success in Symfony2.</p>
  
  <p>In order to do that I have extended <code>AuthenticationSuccessHandlerInterface</code> creating a service for the form login in order to be its success handler.</p>
  
  <p>Here is the firewall in the security.yml file (where the success handler is declared):</p>
  
  <pre><code>firewalls:
      main:
          pattern: ^/
          form_login:
              check_path: fos_user_security_check
              provider: fos_userbundle
              csrf_provider: form.csrf_provider
              success_handler: foo_user.component.authentication.handler.login_success_handler 
          logout:       true
          anonymous:    true 
  </code></pre>
  
  <p>Here is the <code>LoginSuccessHandler</code> service (created in the UserBundle):</p>
  
  <pre><code>namespace Foo\UserBundle\Component\Authentication\Handler;
  
  use Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface;
  use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
  use Symfony\Component\Security\Core\SecurityContext;
  use Symfony\Component\HttpFoundation\Request;
  use Symfony\Component\HttpFoundation\RedirectResponse;
  use Symfony\Component\Routing\Router;
  
  class LoginSuccessHandler implements AuthenticationSuccessHandlerInterface
  {
  
      protected $router;
      protected $security;
  
      public function __construct(Router $router, SecurityContext $security)
      {
          $this-&gt;router = $router;
          $this-&gt;security = $security;
      }
  
      public function onAuthenticationSuccess(Request $request, TokenInterface $token)
     {
          $referer_url = $request-&gt;headers-&gt;get('referer');                       
          $response = new RedirectResponse($referer_url);
  
          return $response;
      }
  }
  </code></pre>
  
  <p>And here is the services.xml from the UserBundle:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; 
  
  &lt;container xmlns="http://symfony.com/schema/dic/services" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"     
  xsi:schemaLocation="http://symfony.com/schema/dic/services 
  http://symfony.com/schema/dic/services/services-1.0.xsd"&gt;
      &lt;parameters&gt;
          &lt;parameter key="foo_user.component.authentication.handler.login_success_handler.class"&gt;
              Foo\UserBundle\Component\Authentication\Handler\LoginSuccessHandler
          &lt;/parameter&gt;
      &lt;/parameters&gt;
      &lt;services&gt;
          &lt;service id="foo_user.component.authentication.handler.login_success_handler" 
          class="%foo_user.component.authentication.handler.login_success_handler.class%"&gt;
              &lt;tag name="monolog.logger" channel="security"/&gt;
              &lt;argument type="service" id="router"/&gt;
              &lt;argument type="service" id="security.context"/&gt;
              &lt;argument type="service" id="service_container"/&gt;
          &lt;/service&gt;
      &lt;/services&gt;
  &lt;/container&gt;
  </code></pre>
  
  <p>The <code>LoginSuccessHandler</code> constructor is being called and I'm getting no error messages.</p>
  
  <p>The problem I'm having is that <code>onAuthenticationSuccess</code> isn't being called after login success. May be I'm missing something?</p>