1 | <?php |
||
23 | class UserRepository |
||
24 | { |
||
25 | /** |
||
26 | * @var array |
||
27 | */ |
||
28 | protected $database = [ |
||
29 | 'user1' => [ |
||
30 | 'password' => '$2y$11$08Snn524ll7Il70xB6aYS.T2kYt57owRzePDYQ.J78vjDjAj22WA6', |
||
31 | 'roles' => ['ROLE_PAGE_1', 'ROLE_API_READ'], |
||
32 | ], |
||
33 | 'user2' => [ |
||
34 | |||
35 | 'password' => '$2y$11$08Snn524ll7Il70xB6aYS.wVlOEQAdvMt4dOE52YSVJo6LhSPebcO', |
||
36 | 'roles' => ['ROLE_PAGE_2', 'ROLE_API_READ'], |
||
37 | ], |
||
38 | 'user3' => [ |
||
39 | 'password' => '$2y$11$08Snn524ll7Il70xB6aYS.VtYPqIhrXpzIw1nsbSkmOGA8nvTjdxS', |
||
40 | 'roles' => ['ROLE_PAGE_3', 'ROLE_API_READ'], |
||
41 | ], |
||
42 | 'admin' => [ |
||
43 | 'password' => '$2y$11$08Snn524ll7Il70xB6aYS.8aU.gMxuV0NqHQAlvXz3th85.1zjI5C', |
||
44 | 'roles' => [Firewall::ROLE_ADMIN], |
||
45 | ], |
||
46 | ]; |
||
47 | |||
48 | /** |
||
49 | * @return array |
||
50 | */ |
||
51 | 4 | public function findAll() |
|
60 | |||
61 | /** |
||
62 | * @param string $name |
||
63 | * |
||
64 | * @return User|bool |
||
65 | */ |
||
66 | 1 | public function findByName($name) |
|
74 | |||
75 | /** |
||
76 | * @param string $name |
||
77 | * @param string $password |
||
78 | * |
||
79 | * @return User|bool |
||
80 | */ |
||
81 | 10 | public function findByNameAndPassword($name, $password) |
|
94 | |||
95 | /** |
||
96 | * Sorry this changes will be not persisted. |
||
97 | * |
||
98 | * @param User $user |
||
99 | * @param string $password |
||
100 | */ |
||
101 | 2 | public function updateUser(User $user, $password) |
|
108 | |||
109 | /** |
||
110 | * Sorry this changes will be not persisted. |
||
111 | * |
||
112 | * @param string $name |
||
113 | */ |
||
114 | public function removeUser($name) |
||
118 | |||
119 | /** |
||
120 | * @param string $password |
||
121 | * |
||
122 | * @return bool|string |
||
123 | */ |
||
124 | 2 | protected function encode($password) |
|
135 | } |
||
136 |