113
113
use Doctrine \ODM \MongoDB \DocumentManager ;
114
114
use Doctrine \ORM \EntityManagerInterface ;
115
115
use Doctrine \ORM \Tools \SchemaTool ;
116
+ use Symfony \Component \Security \Core \Encoder \UserPasswordEncoderInterface ;
116
117
117
118
/**
118
119
* Defines application features from the specific context.
@@ -124,6 +125,7 @@ final class DoctrineContext implements Context
124
125
*/
125
126
private $ manager ;
126
127
private $ doctrine ;
128
+ private $ passwordEncoder ;
127
129
private $ schemaTool ;
128
130
private $ schemaManager ;
129
131
private $ classes ;
@@ -135,9 +137,10 @@ final class DoctrineContext implements Context
135
137
* You can also pass arbitrary arguments to the
136
138
* context constructor through behat.yml.
137
139
*/
138
- public function __construct (ManagerRegistry $ doctrine )
140
+ public function __construct (ManagerRegistry $ doctrine, UserPasswordEncoderInterface $ passwordEncoder )
139
141
{
140
142
$ this ->doctrine = $ doctrine ;
143
+ $ this ->passwordEncoder = $ passwordEncoder ;
141
144
$ this ->manager = $ doctrine ->getManager ();
142
145
$ this ->schemaTool = $ this ->manager instanceof EntityManagerInterface ? new SchemaTool ($ this ->manager ) : null ;
143
146
$ this ->schemaManager = $ this ->manager instanceof DocumentManager ? $ this ->manager ->getSchemaManager () : null ;
@@ -946,8 +949,7 @@ public function thereAreNodesInAContainer(int $nb, string $uuid)
946
949
public function thePasswordForUserShouldBeHashed (string $ password , string $ user )
947
950
{
948
951
$ user = $ this ->doctrine ->getRepository ($ this ->isOrm () ? User::class : UserDocument::class)->find ($ user );
949
-
950
- if (!password_verify ($ password , $ user ->getPassword ())) {
952
+ if (!$ this ->passwordEncoder ->isPasswordValid ($ user , $ password )) {
951
953
throw new \Exception ('User password mismatch ' );
952
954
}
953
955
}
0 commit comments