File tree Expand file tree Collapse file tree 1 file changed +10
-8
lines changed
src/Barnetik/DoctrineAuth Expand file tree Collapse file tree 1 file changed +10
-8
lines changed Original file line number Diff line number Diff line change 10
10
*/
11
11
class DoctrineUserProvider implements UserProvider
12
12
{
13
+ private $ em ;
13
14
private $ userMapper ;
14
-
15
+
15
16
public function __construct (EntityManagerInterface $ entityManager , $ model ) {
17
+ $ this ->em = $ entityManager ;
16
18
$ this ->userMapper = $ entityManager ->getRepository ($ model );
17
19
}
18
20
19
21
public function retrieveById ($ identifier ) {
20
22
return $ this ->userMapper ->find ($ identifier );
21
23
}
22
-
24
+
23
25
public function retrieveByCredentials (array $ credentials ) {
24
26
$ criteria = [];
25
27
foreach ($ credentials as $ key => $ value ) {
@@ -29,24 +31,24 @@ public function retrieveByCredentials(array $credentials) {
29
31
}
30
32
return $ this ->userMapper ->findOneBy ($ criteria );
31
33
}
32
-
34
+
33
35
public function validateCredentials (UserContract $ user , array $ credentials ) {
34
36
$ userPass = $ user ->getAuthPassword ();
35
37
$ pass = $ credentials ['password ' ];
36
38
return password_verify ($ pass , $ userPass );
37
39
}
38
-
40
+
39
41
public function retrieveByToken ($ identifier , $ token ) {
40
42
return $ this ->userMapper ->findOneBy ([
41
43
"id " => $ identifier ,
42
44
"rememberToken " => $ token
43
45
]);
44
46
}
45
-
47
+
46
48
public function updateRememberToken (UserContract $ user , $ token ) {
47
49
$ user ->setRememberToken ($ token );
48
- \Doctrine:: persist ($ user );
49
- \Doctrine:: flush ();
50
+ $ this -> em -> persist ($ user );
51
+ $ this -> em -> flush ();
50
52
}
51
-
53
+
52
54
}
You can’t perform that action at this time.
0 commit comments