Skip to content

Commit 15962e8

Browse files
committed
minor #1459 Simplify logout (javiereguiluz)
This PR was squashed before being merged into the main branch. Discussion ---------- Simplify logout I checked the list of Symfony 6.4 features, and this is the only one that I think it fits this application. So, let's use it. Commits ------- 10277e6 Simplify logout
2 parents d802a81 + 10277e6 commit 15962e8

File tree

3 files changed

+1
-15
lines changed

3 files changed

+1
-15
lines changed

config/packages/security.yaml

-2
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ security:
4949
#always_remember_me: true
5050

5151
logout:
52-
# The route name the user can go to in order to logout
53-
path: security_logout
5452
# The name of the route to redirect to after logging out
5553
target: homepage
5654
# Secure the logout against CSRF

src/Controller/SecurityController.php

-12
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,4 @@ public function login(
5959
'error' => $helper->getLastAuthenticationError(),
6060
]);
6161
}
62-
63-
/**
64-
* This is the route the user can use to logout.
65-
*
66-
* But, this will never be executed. Symfony will intercept this first
67-
* and handle the logout automatically. See logout in config/packages/security.yaml
68-
*/
69-
#[Route('/logout', name: 'security_logout')]
70-
public function logout(): void
71-
{
72-
throw new \Exception('This should never be reached!');
73-
}
7462
}

tests/Controller/UserControllerTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public function testChangePassword(): void
104104

105105
$this->assertResponseRedirects();
106106
$this->assertStringStartsWith(
107-
'/en/logout',
107+
'/logout',
108108
$client->getResponse()->headers->get('Location') ?? '',
109109
'Changing password logout the user.'
110110
);

0 commit comments

Comments
 (0)