Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony2.1: Unable to find the controller for path "/login_check"

I used the "Using a traditional login form" tutorial from symfony.com to authentificate my users. With a simple http auth it works great.

After the login was submitted I get this Exception:

Unable to find the controller for path "/login_check". Maybe you forgot to add the matching route in your routing configuration?

Well, in the tutorial I read:

You will not need to implement a controller for the /login_check URL as the firewall will automatically catch and process any form submitted to this URL.

I defined the routes and set the firewall settings:

security.yml

firewalls:
    dev:
        pattern:  ^/(_(profiler|wdt)|css|images|js)/
        security: false
    backend:
        pattern:    ^/backend
        anonymous: ~
        form_login:
            provider: entity
            login_path: /login
            check_path: /login_check
            #use_forward: true
        logout:
            path:   /logout
            target: /

routing.yml

login:
    pattern:   /login
    defaults:  { _controller: VitaSecurityBundle:Default:login }
login_check:
    pattern:   /login_check
logout:
    pattern:   /logout
like image 716
falsch Avatar asked Sep 13 '12 15:09

falsch


1 Answers

The problem you are having is described here:

See http://symfony.com/doc/current/book/security.html, section "Avoid Common Pitfalls"

  1. Be sure /login_check is behind a firewall Next, make sure that your check_path URL (e.g. /login_check) is behind the firewall you're using for your form login (in this example, the single firewall matches all URLs, including /login_check). If /login_check doesn't match any firewall, you'll receive a Unable to find the controller for path "/login_check" exception.

In this example, your pattern specifies a prefix of /backend for secured paths. To work, your login check should be behind this same firewall.

So, to match the pattern which you have specified in your firewall, put login_check on a url path like this: /backend/login_check

like image 121
Żabojad Avatar answered Sep 20 '22 18:09

Żabojad