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:
33
33
App\EventSubscriber\CommentNotificationSubscriber :
34
34
$sender : ' %app.notifications.email_sender%'
35
35
36
+ Symfony\Component\Security\Http\Logout\LogoutUrlGenerator : ' @security.logout_url_generator'
37
+
36
38
when@test :
37
39
services :
38
40
test.user_password_hasher :
Original file line number Diff line number Diff line change 22
22
use Symfony \Component \Routing \Annotation \Route ;
23
23
use Symfony \Component \Security \Http \Attribute \CurrentUser ;
24
24
use Symfony \Component \Security \Http \Attribute \IsGranted ;
25
+ use Symfony \Component \Security \Http \Logout \LogoutUrlGenerator ;
25
26
26
27
/**
27
28
* Controller used to manage current user. The #[CurrentUser] attribute
@@ -63,6 +64,7 @@ public function changePassword(
63
64
Request $ request ,
64
65
UserPasswordHasherInterface $ passwordHasher ,
65
66
EntityManagerInterface $ entityManager ,
67
+ LogoutUrlGenerator $ logoutUrlGenerator ,
66
68
): Response {
67
69
$ form = $ this ->createForm (ChangePasswordType::class);
68
70
$ form ->handleRequest ($ request );
@@ -74,7 +76,7 @@ public function changePassword(
74
76
$ user ->setPassword ($ passwordHasher ->hashPassword ($ user , $ plainPassword ));
75
77
$ entityManager ->flush ();
76
78
77
- return $ this ->redirectToRoute ( ' security_logout ' );
79
+ return $ this ->redirect ( $ logoutUrlGenerator -> getLogoutPath () );
78
80
}
79
81
80
82
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
93
93
'change_password[newPassword][second] ' => $ newUserPassword ,
94
94
]);
95
95
96
- $ this ->assertResponseRedirects (
96
+ $ this ->assertResponseRedirects ();
97
+ $ this ->assertStringStartsWith (
97
98
'/en/logout ' ,
98
- Response:: HTTP_FOUND ,
99
+ $ client -> getResponse ()-> headers -> get ( ' Location ' ) ?? '' ,
99
100
'Changing password logout the user. '
100
101
);
101
102
}
You can’t perform that action at this time.
0 commit comments