2

It's a common problem, there are lots of hints but i'm currently unable to solve it. Maybe someone can help me.

My security.yml:

firewalls:
    login:
      pattern:  ^/login$
      anonymous:  ~

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

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

And these are my configured routes (router:debug output):

home                     ANY    ANY    ANY  /
login                    ANY    ANY    ANY  /login
logout                   ANY    ANY    ANY  /logout
login_check              ANY    ANY    ANY  /login_check

I would like to have everything in a secured area. But I still getting the error mentioned above: Unable to find the controller for path "/login_check". What wrong with my configuration?

4

2 回答 2

1

在您的 security.yml 中,您可以通过 uri 或路由名称定义 check_path。请尝试使用路线名称,例如,

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

或者您可以像这样在 securityController 中创建自定义安全检查路径,

/**
 * @Route("/login_check", name="_security_check")
 */
 public function securityCheckAction()
 {

 }

您可以check_path: _security_check在安全配置文件中定义

于 2013-06-12T20:15:58.500 回答
0

这很疯狂。Symfony 没有错误。我在前端使用 Jquerymobile 1.3.1,每次登录后浏览器中的 url 都指向http://myapp.localhost/app_dev.php/login_check。登录后我得到了正确的内容,但是在查看源代码时我看到了错误:找不到路径“/login_check”的控制器。当我使用浏览器刷新按钮时,我看到了经典的 symfony 2 故障站点。

当我删除所有 jquerymobile js 和 css 时,登录系统按预期工作。也许我需要将登录表单从 post 更改为某种 ajax 提交。

于 2013-06-13T10:12:06.987 回答