1 | <?php |
||
22 | class UserSetup { |
||
23 | |||
24 | /** |
||
25 | * Gets a closure for possibly generating a password hash in the entity. |
||
26 | * |
||
27 | * @param Data $data |
||
28 | * the Data instance managing the users |
||
29 | * |
||
30 | * @param string $passwordField |
||
31 | * the Entity fieldname of the password hash |
||
32 | * |
||
33 | * @param string $saltField |
||
34 | * the Entity fieldname of the password hash salt |
||
35 | */ |
||
36 | protected function getPWHashFunction(Data $data, $passwordField, $saltField) { |
||
64 | |||
65 | /** |
||
66 | * Determines whether the entity needs a new hash generated. |
||
67 | * |
||
68 | * @param Data $data |
||
69 | * the CRUDlex data instance of the user entity |
||
70 | * @param Entity $entity |
||
71 | * the entity |
||
72 | * @param string $passwordField |
||
73 | * the field holding the password hash in the entity |
||
74 | * @param string $password |
||
75 | * the current password hash |
||
76 | * @param boolean $newSalt |
||
77 | * whether a new password hash salt was generated |
||
78 | * |
||
79 | * @return boolean |
||
80 | * true if the entity needs a new hash |
||
81 | */ |
||
82 | public function doGenerateHash(Data $data, Entity $entity, $passwordField, $password, $newSalt) { |
||
91 | |||
92 | /** |
||
93 | * Generates a random salt of the given length. |
||
94 | * |
||
95 | * @param int $len |
||
96 | * the desired length |
||
97 | * |
||
98 | * @return string |
||
99 | * a random salt of the given length |
||
100 | */ |
||
101 | public function getSalt($len) { |
||
110 | |||
111 | /** |
||
112 | * Setups CRUDlex with some events so the passwords get salted and |
||
113 | * hashed properly. |
||
114 | * |
||
115 | * @param Data $data |
||
116 | * the Data instance managing the users |
||
117 | * |
||
118 | * @param string $passwordField |
||
119 | * the Entity fieldname of the password hash |
||
120 | * |
||
121 | * @param string $saltField |
||
122 | * the Entity fieldname of the password hash salt |
||
123 | */ |
||
124 | public function addEvents(Data $data, $passwordField = 'password', $saltField = 'salt') { |
||
141 | |||
142 | } |
||
143 |