dongzhenqi2015 2012-08-23 09:38
浏览 30
已采纳

找不到Symfony2注销控制器

I have managed to get the login working in Symfony2, but I have trouble with /logout. I get an exception saying it can't find the controller for the route. However, I was under the impression that Symfony deals with the logout process, just like it deals with the login?

(part of) my security.yml file:

firewalls:
    login_firewall:
        pattern:    ^/login/
        anonymous:  ~
    secured_area:
        pattern:    ^/(dashboard|directories|login_check)/
        anonymous: ~
        form_login:
            login_path:  /login/
            check_path:  /login_check/
        logout:
            path:   /logout/
            target: /

My (relevant) routes:

_login:
    pattern: /login/
    defaults: { _controller: NanoBundle:Login:index } 

_login_check:
    pattern: /login_check/

_logout:
    pattern: /logout/

--edit: logout button code:

<a href="{{path('_logout')}}">Logout</a>
  • 写回答

2条回答 默认 最新

  • dongzhang1875 2012-08-25 17:56
    关注

    I eventually fixed it with this security.yml section:

        secured_area:
            pattern:    .*
            security: true
            form_login:
                login_path:  /login/
                check_path:  /login_check/
            logout:
                path: /logout/
                invalidate_session: true
    

    thanks to everyone for trying to help out on this :)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 个人网站被恶意大量访问,怎么办
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制