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) { |
||
59 | |||
60 | /** |
||
61 | * Generates a new salt if the given salt is null. |
||
62 | * |
||
63 | * @param string $salt |
||
64 | * the salt to override if null |
||
65 | * @param Entity |
||
66 | * the entity getting the new salt |
||
67 | * @param string $saltField |
||
68 | * the field holding the salt in the entity |
||
69 | * |
||
70 | * @return boolean |
||
71 | * true if a new salt was generated |
||
72 | */ |
||
73 | public function possibleGenSalt(&$salt, Entity $entity, $saltField) { |
||
81 | |||
82 | /** |
||
83 | * Determines whether the entity needs a new hash generated. |
||
84 | * |
||
85 | * @param Data $data |
||
86 | * the CRUDlex data instance of the user entity |
||
87 | * @param Entity $entity |
||
88 | * the entity |
||
89 | * @param string $passwordField |
||
90 | * the field holding the password hash in the entity |
||
91 | * @param string $password |
||
92 | * the current password hash |
||
93 | * @param boolean $newSalt |
||
94 | * whether a new password hash salt was generated |
||
95 | * |
||
96 | * @return boolean |
||
97 | * true if the entity needs a new hash |
||
98 | */ |
||
99 | public function doGenerateHash(Data $data, Entity $entity, $passwordField, $password, $newSalt) { |
||
108 | |||
109 | /** |
||
110 | * Generates a random salt of the given length. |
||
111 | * |
||
112 | * @param int $len |
||
113 | * the desired length |
||
114 | * |
||
115 | * @return string |
||
116 | * a random salt of the given length |
||
117 | */ |
||
118 | public function getSalt($len) { |
||
127 | |||
128 | /** |
||
129 | * Setups CRUDlex with some events so the passwords get salted and |
||
130 | * hashed properly. |
||
131 | * |
||
132 | * @param Data $data |
||
133 | * the Data instance managing the users |
||
134 | * |
||
135 | * @param string $passwordField |
||
136 | * the Entity fieldname of the password hash |
||
137 | * |
||
138 | * @param string $saltField |
||
139 | * the Entity fieldname of the password hash salt |
||
140 | */ |
||
141 | public function addEvents(Data $data, $passwordField = 'password', $saltField = 'salt') { |
||
158 | |||
159 | } |
||
160 |