Symfony 5.0.5自定义注销。手动多次注销

问题描述 投票:0回答:1

我正在使用Symfony 5.0.5。该Web应用程序具有管理员后台办公室和其他客户后台办公室或“客户”的客户信息]

我有多个登录到我的应用程序的路由。我正在尝试实现多个注销路由器,因为我需要对每种情况进行检查或采取一些措施

security.yaml

    firewalls:
        dev:
            pattern: ^/(_(profiler|wdt)|css|images|js)/
            security: false
        main:
            anonymous: lazy

account.yaml

account_logout:
    path:     logout/comom
    controller: App\Controller\Security\SecurityController::logout
    methods: [GET]
account_customer_logout:
    path:     logout/customer
    controller: App\Controller\Security\SecurityController::logoutCustomer
    methods: [GET]

SecurityController.php

   public function logout()
    {
        $this->get('security.token_storage')->setToken(null);
        $this->get('session')->invalidate();
        // some stuff
        return new RedirectResponse($this->generateUrl("account_login"));
    }

    public function logoutCustomer()
    {
        $this->get('security.token_storage')->setToken(null);
        $this->get('session')->invalidate();
        // some stuff
        return new RedirectResponse($this->generateUrl("login_customer"));
    }

有什么建议吗?

logout symfony5
1个回答
0
投票

我发现了!

只需将匿名更改为true

   firewalls:
        dev:
            pattern: ^/(_(profiler|wdt)|css|images|js)/
            security: false
        main:
            anonymous: true
© www.soinside.com 2019 - 2024. All rights reserved.