From 10277e6153e0e5d3a018e49d52dcdb8f865eaa97 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 23 Nov 2023 12:40:49 +0100 Subject: [PATCH] Simplify logout --- config/packages/security.yaml | 2 -- src/Controller/SecurityController.php | 12 ------------ tests/Controller/UserControllerTest.php | 2 +- 3 files changed, 1 insertion(+), 15 deletions(-) diff --git a/config/packages/security.yaml b/config/packages/security.yaml index 3eb0fd1e1..6a4271bd0 100644 --- a/config/packages/security.yaml +++ b/config/packages/security.yaml @@ -49,8 +49,6 @@ security: #always_remember_me: true logout: - # The route name the user can go to in order to logout - path: security_logout # The name of the route to redirect to after logging out target: homepage # Secure the logout against CSRF diff --git a/src/Controller/SecurityController.php b/src/Controller/SecurityController.php index e1346883e..1b724fa07 100644 --- a/src/Controller/SecurityController.php +++ b/src/Controller/SecurityController.php @@ -59,16 +59,4 @@ public function login( 'error' => $helper->getLastAuthenticationError(), ]); } - - /** - * This is the route the user can use to logout. - * - * But, this will never be executed. Symfony will intercept this first - * and handle the logout automatically. See logout in config/packages/security.yaml - */ - #[Route('/logout', name: 'security_logout')] - public function logout(): void - { - throw new \Exception('This should never be reached!'); - } } diff --git a/tests/Controller/UserControllerTest.php b/tests/Controller/UserControllerTest.php index 023071fe7..f7b80a241 100644 --- a/tests/Controller/UserControllerTest.php +++ b/tests/Controller/UserControllerTest.php @@ -104,7 +104,7 @@ public function testChangePassword(): void $this->assertResponseRedirects(); $this->assertStringStartsWith( - '/en/logout', + '/logout', $client->getResponse()->headers->get('Location') ?? '', 'Changing password logout the user.' );