无法找到路径“/login_check"的控制器 [英] Unable to find the controller for path "/login_check"

查看:56
本文介绍了无法找到路径“/login_check"的控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法在 symfony 上进行用户身份验证.我的 login_path 工作正常,但 check_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?

我看过其他帖子,他们似乎都在做我正在做的事情.我对 symfony 很陌生,无法掌握概念,因此非常感谢您的帮助.

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.

我使用的是 Symfony 2.1,如果这有区别的话.

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

我相信我已经正确配置了一切:

I believe that I have everything configured properly:

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

推荐答案

login_check 路径需要在您的安全区域内.

The login_check path needs to be within your secured area.

在您的代码中,Pattern 定义了前缀/secured",因此您的 login_check 也需要以/secured"为前缀.

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

在您的情况下,安全防火墙定义所有路径都以前缀 /secured 开头,但您的登录检查路径的路径是 /login_check.因此防火墙无法处理该表单.

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.

我认为您也应该将其从 login_firewall 中删除.

I think you should remove it from login_firewall as well.

这篇关于无法找到路径“/login_check"的控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆