title: Symfony: Firewalls, multiple login forms
body: <p>I am not new to symfony by any means, but I've always used <code>FOSUserBundle</code> which by default prevents one from having 2 different login forms for authenticating two different user types..</p>
  
  <p>I have two entities, one is <code>Admins</code> and the other is <code>Users</code>.  Admins will only be able to login in the administration area and likewise users will only be able to login via the front end.</p>
  
  <p>I've followed:  <a href="http://symfony.com/doc/2.1/book/security.html">http://symfony.com/doc/2.1/book/security.html</a>  which also lead me to <a href="http://symfony.com/doc/2.1/cookbook/security/entity_provider.html">http://symfony.com/doc/2.1/cookbook/security/entity_provider.html</a></p>
  
  <p>My security.yml is:</p>
  
  <pre><code>jms_security_extra:
      secure_all_services: false
      expressions: true
  
  security:
      encoders:
          Symfony\Component\Security\Core\User\User: sha512
          Fm\AdminBundle\Entity\Admins: sha512
          Fm\MainBundle\Entity\Users: sha512
  
      role_hierarchy:
          ROLE_ADMIN:       ROLE_USER
          ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]
  
      providers:
          chain_provider:
              chain:
                  providers: [in_memory, admin]
          in_memory:
              memory:
                  users:
                      user:  { password: userpass, roles: [ 'ROLE_USER' ] }
                      admin: { password: adminpass, roles: [ 'ROLE_ADMIN' ] }
  
          admin:
              entity: { class: Fm\AdminBundle\Entity\Admins, property: username }
  
  
      firewalls:
          dev:
              pattern:  ^/(_(profiler|wdt)|css|images|js)/
              security: false
              anonymous: true
  
          alogin:
              pattern:  ^/admin/login
              security: false
          login:
              pattern:  ^/login
              security: false
          secured_area:
              pattern:    ^/admin
              anonymous: false
              provider: chain_provider
              switch_user: true
              form_login:
                  check_path: /admin/login_check
                  login_path: /admin/login
              logout:
                  path:   /admin/logout
                  target: /admin
          members_area:
              pattern: ^/
              anonymous: false
              form_login: ~
              logout:
                  path: /logout
                  target: /
              #anonymous: ~
              #http_basic:
              #    realm: "Secured Demo Area"
  
      access_control:
          - { path: ^/admin/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
          - { path: ^/admin/, roles: ROLE_ADMIN }
  </code></pre>
  
  <p>In my routes I have defined the routes as in the docs: (defaults to /admin/login and /admin/login_check because of my main routing include where /admin is set)</p>
  
  <pre><code>_admin_login:
      pattern:   /login
      defaults:  { _controller: FmAdminBundle:Security:login }
  
  _admin_login_check:
      pattern:   /login_check
  </code></pre>
  
  <p>The error that I am getting in the browser is:</p>
  
  <p><code>Unable to find the controller for path "/admin/login_check". Maybe you forgot to add the matching route in your routing configuration?</code></p>
  
  <p>The stack trace is telling me:  <code>WARNING - Unable to look for the controller as the "_controller" parameter is missing</code></p>
  
  <p>AND </p>
  
  <p><code>ERROR - Symfony\Component\HttpKernel\Exception\NotFoundHttpException: Unable to find the controller for path "/admin/login_check". Maybe you forgot to add the matching route in your routing configuration? (uncaught exception) at /var/www/mysite.dev/symfony/app/bootstrap.php.cache line 1419</code></p>