1 | <?php |
||
22 | class UserSetup { |
||
23 | |||
24 | /** |
||
25 | * Generates a new salt if the given salt is null. |
||
26 | * |
||
27 | * @param string $salt |
||
28 | * the salt to override if null |
||
29 | * @param Entity |
||
30 | * the entity getting the new salt |
||
31 | * @param string $saltField |
||
32 | * the field holding the salt in the entity |
||
33 | * |
||
34 | * @return boolean |
||
35 | * true if a new salt was generated |
||
36 | */ |
||
37 | public function possibleGenSalt(&$salt, Entity $entity, $saltField) { |
||
45 | |||
46 | /** |
||
47 | * Determines whether the entity needs a new hash generated. |
||
48 | * |
||
49 | * @param Data $data |
||
50 | * the CRUDlex data instance of the user entity |
||
51 | * @param Entity $entity |
||
52 | * the entity |
||
53 | * @param string $passwordField |
||
54 | * the field holding the password hash in the entity |
||
55 | * @param string $password |
||
56 | * the current password hash |
||
57 | * @param boolean $newSalt |
||
58 | * whether a new password hash salt was generated |
||
59 | * |
||
60 | * @return boolean |
||
61 | * true if the entity needs a new hash |
||
62 | */ |
||
63 | public function doGenerateHash(Data $data, Entity $entity, $passwordField, $password, $newSalt) { |
||
72 | |||
73 | /** |
||
74 | * Generates a random salt of the given length. |
||
75 | * |
||
76 | * @param int $len |
||
77 | * the desired length |
||
78 | * |
||
79 | * @return string |
||
80 | * a random salt of the given length |
||
81 | */ |
||
82 | public function getSalt($len) { |
||
91 | |||
92 | /** |
||
93 | * Setups CRUDlex with some events so the passwords get salted and |
||
94 | * hashed properly. |
||
95 | * |
||
96 | * @param Data $data |
||
97 | * the Data instance managing the users |
||
98 | * |
||
99 | * @param string $passwordField |
||
100 | * the Entity fieldname of the password hash |
||
101 | * |
||
102 | * @param string $saltField |
||
103 | * the Entity fieldname of the password hash salt |
||
104 | */ |
||
105 | public function addEvents(Data $data, $passwordField = 'password', $saltField = 'salt') { |
||
142 | |||
143 | } |
||
144 |