1 | <?php |
||
23 | class UserSetup { |
||
24 | |||
25 | /** |
||
26 | * The encoder to use. |
||
27 | */ |
||
28 | protected $encoder; |
||
29 | |||
30 | /** |
||
31 | * Gets a closure for possibly generating a password hash in the entity. |
||
32 | * |
||
33 | * @param AbstractData $data |
||
34 | * the AbstractData instance managing the users |
||
35 | * |
||
36 | * @param string $passwordField |
||
37 | * the Entity fieldname of the password hash |
||
38 | * |
||
39 | * @param string $saltField |
||
40 | * the Entity fieldname of the password hash salt |
||
41 | */ |
||
42 | protected function getPWHashFunction(AbstractData $data, $passwordField, $saltField) { |
||
64 | |||
65 | /** |
||
66 | * Constructor. |
||
67 | * |
||
68 | * @param PasswordEncoderInterface $encoder |
||
69 | * the encoder to use, defaults to BCryptPasswordEncoder if null is given |
||
70 | */ |
||
71 | public function __construct(PasswordEncoderInterface $encoder = null) { |
||
77 | |||
78 | /** |
||
79 | * Generates a new salt if the given salt is null. |
||
80 | * |
||
81 | * @param string $salt |
||
82 | * the salt to override if null |
||
83 | * @param Entity |
||
84 | * the entity getting the new salt |
||
85 | * @param string $saltField |
||
86 | * the field holding the salt in the entity |
||
87 | * |
||
88 | * @return boolean |
||
89 | * true if a new salt was generated |
||
90 | */ |
||
91 | public function possibleGenSalt(&$salt, Entity $entity, $saltField) { |
||
99 | |||
100 | /** |
||
101 | * Determines whether the entity needs a new hash generated. |
||
102 | * |
||
103 | * @param AbstractData $data |
||
104 | * the CRUDlex data instance of the user entity |
||
105 | * @param Entity $entity |
||
106 | * the entity |
||
107 | * @param string $passwordField |
||
108 | * the field holding the password hash in the entity |
||
109 | * @param string $password |
||
110 | * the current password hash |
||
111 | * @param boolean $newSalt |
||
112 | * whether a new password hash salt was generated |
||
113 | * |
||
114 | * @return boolean |
||
115 | * true if the entity needs a new hash |
||
116 | */ |
||
117 | public function doGenerateHash(AbstractData $data, Entity $entity, $passwordField, $password, $newSalt) { |
||
126 | |||
127 | /** |
||
128 | * Generates a random salt of the given length. |
||
129 | * |
||
130 | * @param int $len |
||
131 | * the desired length |
||
132 | * |
||
133 | * @return string |
||
134 | * a random salt of the given length |
||
135 | */ |
||
136 | public function getSalt($len) { |
||
145 | |||
146 | /** |
||
147 | * Setups CRUDlex with some events so the passwords get salted and |
||
148 | * hashed properly. |
||
149 | * |
||
150 | * @param AbstractData $data |
||
151 | * the AbstractData instance managing the users |
||
152 | * |
||
153 | * @param string $passwordField |
||
154 | * the Entity fieldname of the password hash |
||
155 | * |
||
156 | * @param string $saltField |
||
157 | * the Entity fieldname of the password hash salt |
||
158 | */ |
||
159 | public function addEvents(AbstractData $data, $passwordField = 'password', $saltField = 'salt') { |
||
176 | |||
177 | } |
||
178 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.