Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to find the controller for path "/login_check"

I have having trouble getting user authentication working on symfony. I have the login_path working properly, but check_path is malfunctioning. The path that I have specified gives the famous Unable to find the controller for path "/login_check". Maybe you forgot to add the matching route in your routing configuration?

I've looked at the other posts, and they all seem to do what I am doing. I am very new to symfony and having trouble grasping the concepts, so I would greatly appreciate some help.

I am using Symfony 2.1, if that makes a difference.

I believe that I have everything configured properly:

security.yml

security:
    encoders:
        Symfony\Component\Security\Core\User\User: plaintext
        Site\CommonBundle\Entity\User: plaintext

    role_hierarchy:
        ROLE_LIGHT:       ROLE_LIGHT
        ROLE_ADMIN:       [ROLE_LIGHT, ROLE_USER]
        ROLE_SUPER_ADMIN: [ROLE_LIGHT, ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]

    providers:
        database:
            entity: { class: SiteCommonBundle:User }

    firewalls:
        dev:
            pattern:  ^/(_(profiler|wdt)|css|images|js)/
            security: false

        login_firewall:
            pattern:  ^/(login|logout|login_check)
            anonymous: ~

        secured:
            pattern: ^/secured/
            form_login:
                login_path: /login
                check_path: /login_check
            logout:
                path: /logout
                target: /


    access_control:
        - { path: ^/secured/, roles:ROLE_LIGHT }
        - { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY}

routing.yml

common_login:
    pattern:  /login
    defaults: { _controller: SiteCommonBundle:Default:login }

common_login_check:
    pattern: /login_check
like image 514
Joseph at SwiftOtter Avatar asked Dec 21 '12 21:12

Joseph at SwiftOtter


1 Answers

The login_check path needs to be within your secured area.

In your code, Pattern defines a prefix of '/secured' so your login_check also needs to be prefixed by '/secured'.

In your case, the secured firewall defines that all paths start with the prefix /secured but the path for your login check path is /login_check. Therefore the firewall cannot handle the form.

I think you should remove it from login_firewall as well.

like image 97
l3l0 Avatar answered Nov 09 '22 22:11

l3l0