我正在使用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"));
}
有什么建议吗?
我发现了!
只需将匿名更改为true
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
anonymous: true