【问题标题】:Symfony4 firewalls logoutSymfony4 防火墙注销
【发布时间】:2018-10-31 04:28:21
【问题描述】:

给我一​​些线索,在 symfony4

的 security.yaml 中添加 logoutlistener

错误: 服务“security.logout_listener.main”依赖于不存在的服务“some.service.id”。

在 security.yaml 中

logout:
                path:   /logout
                target: /login
                invalidate_session: false
                delete_cookies:
                    a: { path: null, domain: null }
                    b: { path: null, domain: null }
                handlers: [some.service.id]

【问题讨论】:

  • 我应该为注销按钮提供什么路径

标签: security logout symfony4


【解决方案1】:

添加这些命令

在 security.yaml 中

logout:
                path:   /logout
                target: /
                invalidate_session: true

在控制器中

    /**
     * @Route("/logout", name="logout")
     */
    public function logout()
    {

    }

退出按钮

<a class="text-muted" href="{{ path('logout') }}">logout </a>

【讨论】:

  • 不需要 cookie 和处理程序
【解决方案2】:

这个link 可以帮助你,所以不要忘记添加你的添加控制器来拥有路由/logout,当你在配置参数中添加这个路由时,防火墙可以自动处理你的注销

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-09-09
    • 1970-01-01
    • 1970-01-01
    • 2016-06-03
    • 2018-08-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多