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 c51单片机控制步进电机
  • ¥20 Visual studio无法检测到设备
  • ¥15 为什么我通过html绘制的SVG折线图插入到word中坐标轴不显示出来
  • ¥30 vue 页面窗口放大或者缩小元素会变化
  • ¥15 questasim仿真报错
  • ¥15 寻找电脑攻防的导师,有问题请教一下。
  • ¥20 微信同是win11,我的电脑安装不了pageoffice,一直无法打开
  • ¥15 这个界面我通过postman请求不到,但是通过浏览器可以正常访问
  • ¥15 多目标优化算法在与其他算法数据对比结果判断
  • ¥15 CPTN和EAST,主干网络是VGG16,请问在ICDAR2015数据集上训练之后,CPTN和EAST模型的大小为多少