Skip to content

Commit

Permalink
Simplify logout
Browse files Browse the repository at this point in the history
  • Loading branch information
javiereguiluz committed Nov 24, 2023
1 parent 38ad58e commit 10277e6
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 15 deletions.
2 changes: 0 additions & 2 deletions config/packages/security.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 0 additions & 12 deletions src/Controller/SecurityController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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!');
}
}
2 changes: 1 addition & 1 deletion tests/Controller/UserControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.'
);
Expand Down

0 comments on commit 10277e6

Please sign in to comment.