File tree Expand file tree Collapse file tree 3 files changed +8
-3
lines changed
Expand file tree Collapse file tree 3 files changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,8 @@ services:
3333 App\EventSubscriber\CommentNotificationSubscriber :
3434 $sender : ' %app.notifications.email_sender%'
3535
36+ Symfony\Component\Security\Http\Logout\LogoutUrlGenerator : ' @security.logout_url_generator'
37+
3638when@test :
3739 services :
3840 test.user_password_hasher :
Original file line number Diff line number Diff line change 2222use Symfony \Component \Routing \Annotation \Route ;
2323use Symfony \Component \Security \Http \Attribute \CurrentUser ;
2424use Symfony \Component \Security \Http \Attribute \IsGranted ;
25+ use Symfony \Component \Security \Http \Logout \LogoutUrlGenerator ;
2526
2627/**
2728 * Controller used to manage current user. The #[CurrentUser] attribute
@@ -63,6 +64,7 @@ public function changePassword(
6364 Request $ request ,
6465 UserPasswordHasherInterface $ passwordHasher ,
6566 EntityManagerInterface $ entityManager ,
67+ LogoutUrlGenerator $ logoutUrlGenerator ,
6668 ): Response {
6769 $ form = $ this ->createForm (ChangePasswordType::class);
6870 $ form ->handleRequest ($ request );
@@ -74,7 +76,7 @@ public function changePassword(
7476 $ user ->setPassword ($ passwordHasher ->hashPassword ($ user , $ plainPassword ));
7577 $ entityManager ->flush ();
7678
77- return $ this ->redirectToRoute ( ' security_logout ' );
79+ return $ this ->redirect ( $ logoutUrlGenerator -> getLogoutPath () );
7880 }
7981
8082 return $ this ->render ('user/change_password.html.twig ' , [
Original file line number Diff line number Diff line change @@ -93,9 +93,10 @@ public function testChangePassword(): void
9393 'change_password[newPassword][second] ' => $ newUserPassword ,
9494 ]);
9595
96- $ this ->assertResponseRedirects (
96+ $ this ->assertResponseRedirects ();
97+ $ this ->assertStringStartsWith (
9798 '/en/logout ' ,
98- Response:: HTTP_FOUND ,
99+ $ client -> getResponse ()-> headers -> get ( ' Location ' ) ?? '' ,
99100 'Changing password logout the user. '
100101 );
101102 }
You can’t perform that action at this time.
0 commit comments