127
127
use Doctrine \ODM \MongoDB \DocumentManager ;
128
128
use Doctrine \ORM \EntityManagerInterface ;
129
129
use Doctrine \ORM \Tools \SchemaTool ;
130
+ use Symfony \Component \Security \Core \Encoder \UserPasswordEncoderInterface ;
130
131
131
132
/**
132
133
* Defines application features from the specific context.
@@ -138,6 +139,7 @@ final class DoctrineContext implements Context
138
139
*/
139
140
private $ manager ;
140
141
private $ doctrine ;
142
+ private $ passwordEncoder ;
141
143
private $ schemaTool ;
142
144
private $ schemaManager ;
143
145
private $ classes ;
@@ -149,9 +151,10 @@ final class DoctrineContext implements Context
149
151
* You can also pass arbitrary arguments to the
150
152
* context constructor through behat.yml.
151
153
*/
152
- public function __construct (ManagerRegistry $ doctrine )
154
+ public function __construct (ManagerRegistry $ doctrine, UserPasswordEncoderInterface $ passwordEncoder )
153
155
{
154
156
$ this ->doctrine = $ doctrine ;
157
+ $ this ->passwordEncoder = $ passwordEncoder ;
155
158
$ this ->manager = $ doctrine ->getManager ();
156
159
$ this ->schemaTool = $ this ->manager instanceof EntityManagerInterface ? new SchemaTool ($ this ->manager ) : null ;
157
160
$ this ->schemaManager = $ this ->manager instanceof DocumentManager ? $ this ->manager ->getSchemaManager () : null ;
@@ -1066,8 +1069,7 @@ public function thereAreNodesInAContainer(int $nb, string $uuid)
1066
1069
public function thePasswordForUserShouldBeHashed (string $ password , string $ user )
1067
1070
{
1068
1071
$ user = $ this ->doctrine ->getRepository ($ this ->isOrm () ? User::class : UserDocument::class)->find ($ user );
1069
-
1070
- if (!password_verify ($ password , $ user ->getPassword ())) {
1072
+ if (!$ this ->passwordEncoder ->isPasswordValid ($ user , $ password )) {
1071
1073
throw new \Exception ('User password mismatch ' );
1072
1074
}
1073
1075
}
0 commit comments