Skip to content

Commit 5081b49

Browse files
committed
Security::logout() returns a redirect response
1 parent 7bbf2ce commit 5081b49

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

src/Controller/UserController.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,9 @@ public function changePassword(
7070
if ($form->isSubmitted() && $form->isValid()) {
7171
$entityManager->flush();
7272

73-
// The second argument is to disable CSRF protection before logout.
74-
// A CSRF token is already verified by the form.
75-
$security->logout(false);
76-
77-
return $this->redirectToRoute('security_login');
73+
// The logout method has a protection against CSRF attacks, it's disabled here
74+
// because the form already has a CSRF token validated.
75+
return $security->logout(false);
7876
}
7977

8078
return $this->render('user/change_password.html.twig', [

tests/Controller/UserControllerTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,9 @@ public function testChangePassword(): void
104104

105105
$this->assertResponseRedirects();
106106
$this->assertResponseRedirects(
107-
'/en/login',
107+
'/',
108108
Response::HTTP_FOUND,
109109
'Changing password logout the user.'
110110
);
111-
112-
$client->followRedirect();
113-
$this->assertResponseStatusCodeSame(Response::HTTP_OK);
114111
}
115112
}

0 commit comments

Comments
 (0)