title: Redirect to different locations based on the role with FOSUserBundle
body: <p>I have looked everywhere, and tried everything, but my redirect still doesn't want to work.</p>
  
  <p>I have done option two of <a href="https://stackoverflow.com/questions/34682205/redirect-to-a-different-homepage-following-user-role-using-fosuserbundle">this</a> question's answer but the wanted results doesn't appear.</p>
  
  <p>This is my overwritten login function (inside <code>/src/Acme/UserBundle/Controller/SecurityController.php</code>);</p>
  
  <pre><code>class SecurityController extends BaseController
  {
      public function loginAction(Request $request)
      {        
          /** @var $session \Symfony\Component\HttpFoundation\Session\Session */
          $session = $request-&gt;getSession();
  
          $authChecker = $this-&gt;container-&gt;get('security.authorization_checker');
          $router = $this-&gt;container-&gt;get('router');
  
          if ($authChecker-&gt;isGranted('ROLE_ADMIN')) {
              return new RedirectResponse($router-&gt;generate('admin_home'), 307);
          } 
  
          if ($authChecker-&gt;isGranted('ROLE_USER')) {
              return new RedirectResponse($router-&gt;generate('user_home'), 307);
          }
          ...
          ...
      }
  }
  </code></pre>
  
  <p>I have my <code>AcmeUserBundle.php</code> inside <code>/src/Acme/UserBundle/</code> containing the following code;</p>
  
  <pre><code>namespace Acme\UserBundle;
  
  use Symfony\Component\HttpKernel\Bundle\Bundle;
  
  class AcmeUserBundle extends Bundle
  {
      public function getParent()
      {
          return 'FOSUserBundle';
      }
  }
  </code></pre>
  
  <p>Then I have my main application bundle <code>AppBundle</code> next to <code>Acme</code> inside <code>/src/</code> with my <code>DefaultController.php</code> inside <code>/Controller/</code> and my admin controller as <code>DefaultController.php</code> inside <code>/Controller/Admin/</code></p>
  
  <p>When I log in with a user with role <code>ROLE_USER</code>, it goes to the correct location. But when I log in with role <code>ROLE_ADMIN</code> he goes to the same location as <code>ROLE_USER</code>. It is suppose to go to the admin page.</p>
  
  <p>This is my <code>security.yml</code> file;</p>
  
  <pre><code>security:
      encoders:
          FOS\UserBundle\Model\UserInterface: bcrypt
  
      role_hierarchy:
          ROLE_ADMIN:       ROLE_USER
          ROLE_SUPER_ADMIN: ROLE_ADMIN
  
      providers:
          fos_userbundle:
              id: fos_user.user_provider.username
  
      firewalls:
          main:
              pattern: ^/
              form_login:
                  provider: fos_userbundle
                  csrf_token_generator: security.csrf.token_manager
              logout:       true
              anonymous:    true
  
      access_control:
          - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
          - { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
          - { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
          - { path: ^/, role: ROLE_USER }
          - { path: ^/admin, role: ROLE_ADMIN }
  </code></pre>
  
  <p>In my project's profiler the user role for a normally registered user state <code>ROLE_USER</code>. I modified a user's role in my database to be <code>ROLE_ADMIN</code> and when I log in with him both roles shows to be assigned to him. Under the <code>role</code> column in my database this is how it looks for a user with <code>ROLE_USER</code> assigned to him : </p>
  
  <blockquote>
    <p>a:0:{}</p>
  </blockquote>
  
  <p>and this is how I modified the other user to have <code>ROLE_ADMIN</code>:</p>
  
  <blockquote>
    <p>a:1:{i:0;s:10:"ROLE_ADMIN";}</p>
  </blockquote>
  
  <p>Is this right? Can somebody please help me to fix this problem?</p>
  
  <p>NOTE: When I sign in with a <code>ROLE_USER</code> user and I modify the url to go to /admin/ I get a "Expression "has_role('ROLE_ADMIN')" denied access." error. I get that, that's fine because I don't want a normal user to access that area. But when I login with a <code>ROLE_ADMIN</code> user and modify the url to /admin/ it does go to that page, so I can see by that that my ROLES are working fine and the routing as well, but the redirect on login not.</p>
  
  <p>Clearing my cache also didn't do the trick.</p>