1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* BB's Zend Framework 2 Components |
4
|
|
|
* |
5
|
|
|
* AdminModule |
6
|
|
|
* |
7
|
|
|
* @package [MyApplication] |
8
|
|
|
* @package BB's Zend Framework 2 Components |
9
|
|
|
* @package AdminModule |
10
|
|
|
* @author Björn Bartels <[email protected]> |
11
|
|
|
* @link https://gitlab.bjoernbartels.earth/groups/zf2 |
12
|
|
|
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0 |
13
|
|
|
* @copyright copyright (c) 2016 Björn Bartels <[email protected]> |
14
|
|
|
*/ |
15
|
|
|
|
16
|
|
|
namespace Admin\Model; |
17
|
|
|
|
18
|
|
|
use Zend\Crypt\Password\Bcrypt; |
19
|
|
|
use Zend\InputFilter\InputFilter; |
20
|
|
|
use Zend\InputFilter\Factory as InputFactory; |
21
|
|
|
use Zend\InputFilter\InputFilterAwareInterface; |
22
|
|
|
use Zend\InputFilter\InputFilterInterface; |
23
|
|
|
use Zend\ServiceManager\ServiceLocator; |
24
|
|
|
use Zend\ServiceManager\ServiceLocatorInterface; |
25
|
|
|
use Zend\ServiceManager\ServiceManager; |
26
|
|
|
use Zend\ServiceManager\ServiceManagerInterface; |
|
|
|
|
27
|
|
|
use Zend\ServiceManager\ServiceLocatorAwareInterface; |
28
|
|
|
use Zend\ServiceManager\ServiceLocatorAwareTrait; |
29
|
|
|
|
30
|
|
|
class User implements InputFilterAwareInterface, ServiceLocatorAwareInterface |
31
|
|
|
{ |
32
|
|
|
use ServiceLocatorAwareTrait; |
33
|
|
|
|
34
|
|
|
public $id; |
35
|
|
|
public $user_id; |
36
|
|
|
public $display_name; |
37
|
|
|
public $username; |
38
|
|
|
public $email; |
39
|
|
|
public $password; |
40
|
|
|
public $state; |
41
|
|
|
public $aclrole; |
42
|
|
|
public $token; |
43
|
|
|
|
44
|
|
|
protected $inputFilter; |
45
|
|
|
protected $userService; |
46
|
|
|
protected $serviceManager; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* set user's object property data |
50
|
|
|
* |
51
|
|
|
* @param array $data |
52
|
|
|
* @param boolean $forceEncryptPassword |
53
|
|
|
* @return \Admin\Entity\User |
54
|
|
|
*/ |
55
|
|
|
public function exchangeArray($data = array(), $forceEncryptPassword = false) |
56
|
|
|
{ |
57
|
|
|
if (isset($data['id']) && !empty($data["id"]) ) { |
58
|
|
|
$this->id = ($data['id']); |
59
|
|
|
$this->user_id = ($data['id']); |
60
|
|
|
} elseif (isset($data['user_id']) && !empty($data["user_id"]) ) { |
61
|
|
|
$this->id = ($data['user_id']); |
62
|
|
|
$this->user_id = ($data['user_id']); |
63
|
|
|
} |
64
|
|
|
$this->username = (isset($data['username'])) ? $data['username'] : $this->username; |
65
|
|
|
$this->email = (isset($data['email'])) ? $data['email'] : $this->email; |
66
|
|
|
if (isset($data['displayName']) ) { |
67
|
|
|
$this->display_name = $data['displayName']; |
68
|
|
|
$this->displayName = $data['displayName']; |
|
|
|
|
69
|
|
|
} elseif (isset($data['display_name']) ) { |
70
|
|
|
$this->display_name = $data['display_name']; |
71
|
|
|
$this->displayName = $data['display_name']; |
72
|
|
|
} |
73
|
|
|
if (isset($data["password"]) && $forceEncryptPassword ) { |
74
|
|
|
$bcrypt = new Bcrypt; |
75
|
|
|
$bcrypt->setCost(null); // @TODO $this->getUserService()->getOptions()->getPasswordCost()); |
76
|
|
|
$data["password"] = $bcrypt->create($data['password']); |
77
|
|
|
} |
78
|
|
|
$this->password = (isset($data['password'])) ? $data['password'] : $this->password; |
79
|
|
|
$this->state = (isset($data['state'])) ? $data['state'] : $this->state; |
80
|
|
|
$this->aclrole = (isset($data['aclrole'])) ? $data['aclrole'] : $this->aclrole; |
81
|
|
|
$this->token = (isset($data['token'])) ? $data['token'] : $this->token; |
82
|
|
|
|
83
|
|
|
return $this; |
|
|
|
|
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
|
87
|
|
|
public function getArrayCopy() |
88
|
|
|
{ |
89
|
|
|
return get_object_vars($this); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
public function setInputFilter(InputFilterInterface $inputFilter) |
93
|
|
|
{ |
94
|
|
|
throw new \Exception("Not used"); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
public function getInputFilter() |
98
|
|
|
{ |
99
|
|
|
if (!$this->inputFilter) { |
100
|
|
|
$inputFilter = new InputFilter(); |
101
|
|
|
$factory = new InputFactory(); |
102
|
|
|
|
103
|
|
|
$inputFilter->add( |
104
|
|
|
$factory->createInput( |
105
|
|
|
array( |
106
|
|
|
'name' => 'user_id', |
107
|
|
|
'required' => true, |
108
|
|
|
'filters' => array( |
109
|
|
|
array('name' => 'Int'), |
110
|
|
|
), |
111
|
|
|
) |
112
|
|
|
) |
113
|
|
|
); |
114
|
|
|
|
115
|
|
|
$inputFilter->add( |
116
|
|
|
$factory->createInput( |
117
|
|
|
array( |
118
|
|
|
'name' => 'username', |
119
|
|
|
'required' => true, |
120
|
|
|
'filters' => array( |
121
|
|
|
array('name' => 'StripTags'), |
122
|
|
|
array('name' => 'StringTrim'), |
123
|
|
|
), |
124
|
|
|
'validators' => array( |
125
|
|
|
array( |
126
|
|
|
'name' => 'StringLength', |
127
|
|
|
'options' => array( |
128
|
|
|
'encoding' => 'UTF-8', |
129
|
|
|
'min' => 1, |
130
|
|
|
'max' => 100, |
131
|
|
|
), |
132
|
|
|
), |
133
|
|
|
), |
134
|
|
|
) |
135
|
|
|
) |
136
|
|
|
); |
137
|
|
|
|
138
|
|
|
$inputFilter->add( |
139
|
|
|
$factory->createInput( |
140
|
|
|
array( |
141
|
|
|
'name' => 'email', |
142
|
|
|
'required' => true, |
143
|
|
|
'filters' => array( |
144
|
|
|
array('name' => 'StripTags'), |
145
|
|
|
array('name' => 'StringTrim'), |
146
|
|
|
), |
147
|
|
|
'validators' => array( |
148
|
|
|
array( |
149
|
|
|
'name' => 'StringLength', |
150
|
|
|
'options' => array( |
151
|
|
|
'encoding' => 'UTF-8', |
152
|
|
|
'min' => 1, |
153
|
|
|
'max' => 100, |
154
|
|
|
), |
155
|
|
|
), |
156
|
|
|
array( |
157
|
|
|
'name' => 'EmailAddress', |
158
|
|
|
), |
159
|
|
|
), |
160
|
|
|
) |
161
|
|
|
) |
162
|
|
|
); |
163
|
|
|
|
164
|
|
|
$inputFilter->add( |
165
|
|
|
$factory->createInput( |
166
|
|
|
array( |
167
|
|
|
'name' => 'display_name', |
168
|
|
|
'required' => true, |
169
|
|
|
'filters' => array( |
170
|
|
|
array('name' => 'StripTags'), |
171
|
|
|
array('name' => 'StringTrim'), |
172
|
|
|
), |
173
|
|
|
'validators' => array( |
174
|
|
|
array( |
175
|
|
|
'name' => 'StringLength', |
176
|
|
|
'options' => array( |
177
|
|
|
'encoding' => 'UTF-8', |
178
|
|
|
'min' => 1, |
179
|
|
|
'max' => 100, |
180
|
|
|
), |
181
|
|
|
), |
182
|
|
|
), |
183
|
|
|
) |
184
|
|
|
) |
185
|
|
|
); |
186
|
|
|
|
187
|
|
|
$inputFilter->add( |
188
|
|
|
$factory->createInput( |
189
|
|
|
array( |
190
|
|
|
'name' => 'password', |
191
|
|
|
'required' => true, |
192
|
|
|
'filters' => array( |
193
|
|
|
array('name' => 'StripTags'), |
194
|
|
|
array('name' => 'StringTrim'), |
195
|
|
|
), |
196
|
|
|
'validators' => array( |
197
|
|
|
array( |
198
|
|
|
'name' => 'StringLength', |
199
|
|
|
'options' => array( |
200
|
|
|
'encoding' => 'UTF-8', |
201
|
|
|
'min' => 6, |
202
|
|
|
'max' => 32, |
203
|
|
|
), |
204
|
|
|
), |
205
|
|
|
), |
206
|
|
|
) |
207
|
|
|
) |
208
|
|
|
); |
209
|
|
|
|
210
|
|
|
$this->inputFilter = $inputFilter; |
211
|
|
|
} |
212
|
|
|
|
213
|
|
|
return $this->inputFilter; |
214
|
|
|
} |
215
|
|
|
/** |
216
|
|
|
* Getters/setters for DI stuff |
217
|
|
|
*/ |
218
|
|
|
|
219
|
|
|
public function getUserService() |
220
|
|
|
{ |
221
|
|
|
if (!$this->userService) { |
222
|
|
|
$this->userService = $this->getServiceManager()->get('zfcuser_user_service'); |
223
|
|
|
} |
224
|
|
|
return $this->userService; |
225
|
|
|
} |
226
|
|
|
|
227
|
|
|
public function setUserService(UserService $userService) |
|
|
|
|
228
|
|
|
{ |
229
|
|
|
$this->userService = $userService; |
230
|
|
|
return $this; |
231
|
|
|
} |
232
|
|
|
|
233
|
|
|
/** |
234
|
|
|
* Retrieve service manager instance |
235
|
|
|
* |
236
|
|
|
* @return ServiceManager |
237
|
|
|
*/ |
238
|
|
|
public function getServiceManager() |
239
|
|
|
{ |
240
|
|
|
return $this->serviceManager; |
241
|
|
|
} |
242
|
|
|
|
243
|
|
|
/** |
244
|
|
|
* Set service manager instance |
245
|
|
|
* |
246
|
|
|
* @param ServiceManager $serviceManager |
247
|
|
|
* @return User |
248
|
|
|
*/ |
249
|
|
|
public function setServiceManager(ServiceManagerInterface $serviceManager) |
250
|
|
|
{ |
251
|
|
|
$this->serviceManager = $serviceManager; |
252
|
|
|
return $this; |
253
|
|
|
} |
254
|
|
|
|
255
|
|
|
} |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths