@@ -34,8 +34,7 @@ |
||
34 | 34 | $args['RawMessage'] = array(); |
35 | 35 | $args['RawMessage']['Data'] = base64_encode($email->getRawMessage()); |
36 | 36 | return $this->ses->sendRawEmail($args); |
37 | - } |
|
38 | - else |
|
37 | + } else |
|
39 | 38 | { |
40 | 39 | $args = array(); |
41 | 40 | $args['Source'] = $email->getFromAddress(); |
@@ -5,13 +5,13 @@ discard block |
||
5 | 5 | { |
6 | 6 | private $data; |
7 | 7 | |
8 | - function __construct($data=false) |
|
8 | + function __construct($data = false) |
|
9 | 9 | { |
10 | 10 | $this->data = array(); |
11 | - if($data !== false) |
|
11 | + if ($data !== false) |
|
12 | 12 | { |
13 | 13 | $this->data = $data; |
14 | - if(isset($data['extended'])) |
|
14 | + if (isset($data['extended'])) |
|
15 | 15 | { |
16 | 16 | $this->data = $data['extended']; |
17 | 17 | } |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | |
21 | 21 | function isInGroupNamed($name) |
22 | 22 | { |
23 | - if(isset($this->data['current_data_set'])) |
|
23 | + if (isset($this->data['current_data_set'])) |
|
24 | 24 | { |
25 | 25 | $auth_data_set = \DataSetFactory::getDataSetByName($this->data['current_data_set']); |
26 | 26 | } |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | $uid = $this->getUid(); |
33 | 33 | $filter = new \Data\Filter("uid eq '$uid' and gid eq '$name'"); |
34 | 34 | $groups = $group_data_table->read($filter); |
35 | - if($groups === false || !isset($groups[0])) |
|
35 | + if ($groups === false || !isset($groups[0])) |
|
36 | 36 | { |
37 | 37 | return false; |
38 | 38 | } |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | |
43 | 43 | function getEmail() |
44 | 44 | { |
45 | - if(isset($this->data['mail'])) |
|
45 | + if (isset($this->data['mail'])) |
|
46 | 46 | { |
47 | 47 | return $this->data['mail']; |
48 | 48 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | |
52 | 52 | function getUid() |
53 | 53 | { |
54 | - if(isset($this->data['uid'])) |
|
54 | + if (isset($this->data['uid'])) |
|
55 | 55 | { |
56 | 56 | return $this->data['uid']; |
57 | 57 | } |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace Auth; |
3 | 3 | |
4 | -if(!function_exists('password_hash') || !function_exists('password_verify')) |
|
4 | +if (!function_exists('password_hash') || !function_exists('password_verify')) |
|
5 | 5 | { |
6 | 6 | define('PASSWORD_BCRYPT', 1); |
7 | 7 | define('PASSWORD_DEFAULT', PASSWORD_BCRYPT); |
@@ -9,22 +9,22 @@ discard block |
||
9 | 9 | |
10 | 10 | function password_hash($password, $algo = PASSWORD_DEFAULT) |
11 | 11 | { |
12 | - if(is_null($password) || is_int($password)) |
|
12 | + if (is_null($password) || is_int($password)) |
|
13 | 13 | { |
14 | 14 | $password = (string)$password; |
15 | 15 | } |
16 | - if(!is_string($password)) |
|
16 | + if (!is_string($password)) |
|
17 | 17 | { |
18 | 18 | trigger_error("password_hash(): Password must be a string", E_USER_WARNING); |
19 | 19 | return false; |
20 | 20 | } |
21 | - if(!is_int($algo)) |
|
21 | + if (!is_int($algo)) |
|
22 | 22 | { |
23 | - trigger_error("password_hash() expects parameter 2 to be long, " . gettype($algo) . " given", E_USER_WARNING); |
|
23 | + trigger_error("password_hash() expects parameter 2 to be long, ".gettype($algo)." given", E_USER_WARNING); |
|
24 | 24 | return false; |
25 | 25 | } |
26 | 26 | $resultLength = 0; |
27 | - switch($algo) |
|
27 | + switch ($algo) |
|
28 | 28 | { |
29 | 29 | case PASSWORD_BCRYPT: |
30 | 30 | $cost = PASSWORD_BCRYPT_DEFAULT_COST; |
@@ -43,9 +43,9 @@ discard block |
||
43 | 43 | $base64String = base64_encode($salt); |
44 | 44 | $salt = strtr(rtrim($base64String, '='), $base64Digits, $bcrypt64Digits); |
45 | 45 | $salt = substr($salt, 0, $requiredSaltLen); |
46 | - $hash = $hashFormat . $salt; |
|
46 | + $hash = $hashFormat.$salt; |
|
47 | 47 | $ret = crypt($password, $hash); |
48 | - if(!is_string($ret) || strlen($ret) != $resultLength) |
|
48 | + if (!is_string($ret) || strlen($ret) != $resultLength) |
|
49 | 49 | { |
50 | 50 | return false; |
51 | 51 | } |
@@ -55,13 +55,13 @@ discard block |
||
55 | 55 | function password_verify($password, $hash) |
56 | 56 | { |
57 | 57 | $ret = crypt($password, $hash); |
58 | - if(!is_string($ret) || strlen($ret) != strlen($hash) || strlen($ret) <= 13) |
|
58 | + if (!is_string($ret) || strlen($ret) != strlen($hash) || strlen($ret) <= 13) |
|
59 | 59 | { |
60 | 60 | return false; |
61 | 61 | } |
62 | 62 | $status = 0; |
63 | 63 | $count = strlen($ret); |
64 | - for($i = 0; $i < $count; $i++) |
|
64 | + for ($i = 0; $i < $count; $i++) |
|
65 | 65 | { |
66 | 66 | $status |= (ord($ret[$i]) ^ ord($hash[$i])); |
67 | 67 | } |
@@ -80,11 +80,11 @@ discard block |
||
80 | 80 | { |
81 | 81 | parent::__construct($params); |
82 | 82 | $this->params = $params; |
83 | - if($this->current) |
|
83 | + if ($this->current) |
|
84 | 84 | { |
85 | 85 | $this->dataSet = $this->getCurrentDataSet(); |
86 | 86 | } |
87 | - if($this->pending) |
|
87 | + if ($this->pending) |
|
88 | 88 | { |
89 | 89 | $this->pendingDataSet = $this->getPendingDataSet(); |
90 | 90 | } |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | */ |
96 | 96 | private function getCurrentDataSet() |
97 | 97 | { |
98 | - if(isset($this->params['current_data_set'])) |
|
98 | + if (isset($this->params['current_data_set'])) |
|
99 | 99 | { |
100 | 100 | return \DataSetFactory::getDataSetByName($this->params['current_data_set']); |
101 | 101 | } |
@@ -107,30 +107,30 @@ discard block |
||
107 | 107 | */ |
108 | 108 | private function getPendingDataSet() |
109 | 109 | { |
110 | - if(isset($this->params['pending_data_set'])) |
|
110 | + if (isset($this->params['pending_data_set'])) |
|
111 | 111 | { |
112 | 112 | return \DataSetFactory::getDataSetByName($this->params['pending_data_set']); |
113 | 113 | } |
114 | 114 | return \DataSetFactory::getDataSetByName('pending_authentication'); |
115 | 115 | } |
116 | 116 | |
117 | - private function getDataTable($name, $pending=false) |
|
117 | + private function getDataTable($name, $pending = false) |
|
118 | 118 | { |
119 | - if(isset($this->dataTables[$name]) && isset($this->dataTables[$name][$pending])) |
|
119 | + if (isset($this->dataTables[$name]) && isset($this->dataTables[$name][$pending])) |
|
120 | 120 | { |
121 | 121 | return $this->dataTables[$name][$pending]; |
122 | 122 | } |
123 | 123 | $dataSet = $this->dataSet; |
124 | - if($pending) |
|
124 | + if ($pending) |
|
125 | 125 | { |
126 | 126 | $dataSet = $this->pendingDataSet; |
127 | 127 | } |
128 | - if($dataSet === null) |
|
128 | + if ($dataSet === null) |
|
129 | 129 | { |
130 | 130 | throw new \Exception('Unable to obtain dataset for SQL Authentication!'); |
131 | 131 | } |
132 | 132 | $dataTable = $dataSet[$name]; |
133 | - if(!isset($this->dataTables[$name])) |
|
133 | + if (!isset($this->dataTables[$name])) |
|
134 | 134 | { |
135 | 135 | $this->dataTables[$name] = array(); |
136 | 136 | } |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | |
141 | 141 | private function getPendingUserDataTable() |
142 | 142 | { |
143 | - if(isset($this->params['pending_user_table'])) |
|
143 | + if (isset($this->params['pending_user_table'])) |
|
144 | 144 | { |
145 | 145 | return $this->getDataTable($this->params['pending_user_table'], true); |
146 | 146 | } |
@@ -149,15 +149,15 @@ discard block |
||
149 | 149 | |
150 | 150 | public function login($username, $password) |
151 | 151 | { |
152 | - if($this->current === false) return false; |
|
152 | + if ($this->current === false) return false; |
|
153 | 153 | $userDataTable = $this->getDataTable('user'); |
154 | 154 | $filter = new \Data\Filter("uid eq '$username'"); |
155 | 155 | $users = $userDataTable->read($filter); |
156 | - if($users === false || !isset($users[0])) |
|
156 | + if ($users === false || !isset($users[0])) |
|
157 | 157 | { |
158 | 158 | return false; |
159 | 159 | } |
160 | - if(password_verify($password, $users[0]['pass'])) |
|
160 | + if (password_verify($password, $users[0]['pass'])) |
|
161 | 161 | { |
162 | 162 | return array('res'=>true, 'extended'=>$users[0]); |
163 | 163 | } |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | |
167 | 167 | public function isLoggedIn($data) |
168 | 168 | { |
169 | - if(isset($data['res'])) |
|
169 | + if (isset($data['res'])) |
|
170 | 170 | { |
171 | 171 | return $data['res']; |
172 | 172 | } |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | |
176 | 176 | public function getUser($data) |
177 | 177 | { |
178 | - if(isset($this->params['current_data_set'])) |
|
178 | + if (isset($this->params['current_data_set'])) |
|
179 | 179 | { |
180 | 180 | $data['current_data_set'] = $this->params['current_data_set']; |
181 | 181 | } |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | $groupDataTable = $this->getDataTable('group'); |
188 | 188 | $filter = new \Data\Filter("gid eq '$name'"); |
189 | 189 | $groups = $groupDataTable->read($filter); |
190 | - if($groups === false || !isset($groups[0])) |
|
190 | + if ($groups === false || !isset($groups[0])) |
|
191 | 191 | { |
192 | 192 | return false; |
193 | 193 | } |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | $userDataTable = $this->getDataTable('user'); |
200 | 200 | $filter = new \Data\Filter("uid eq '$name'"); |
201 | 201 | $users = $userDataTable->read($filter); |
202 | - if($users === false || !isset($users[0])) |
|
202 | + if ($users === false || !isset($users[0])) |
|
203 | 203 | { |
204 | 204 | return false; |
205 | 205 | } |
@@ -215,33 +215,33 @@ discard block |
||
215 | 215 | private function convertDataToClass($dataTableName, $className, $filter, $select, $top, $skip, $orderby) |
216 | 216 | { |
217 | 217 | $data = $this->getDataByFilter($dataTableName, $filter, $select, $top, $skip, $orderby); |
218 | - if($data === false) |
|
218 | + if ($data === false) |
|
219 | 219 | { |
220 | 220 | return false; |
221 | 221 | } |
222 | 222 | $count = count($data); |
223 | - for($i = 0; $i < $count; $i++) |
|
223 | + for ($i = 0; $i < $count; $i++) |
|
224 | 224 | { |
225 | 225 | $data[$i] = new $className($groups[$i]); |
226 | 226 | } |
227 | 227 | return $data; |
228 | 228 | } |
229 | 229 | |
230 | - public function getGroupsByFilter($filter, $select=false, $top=false, $skip=false, $orderby=false) |
|
230 | + public function getGroupsByFilter($filter, $select = false, $top = false, $skip = false, $orderby = false) |
|
231 | 231 | { |
232 | 232 | return $this->convertDataToClass('group', 'SQLGroup', $filter, $select, $top, $skip, $orderby); |
233 | 233 | } |
234 | 234 | |
235 | - public function getUsersByFilter($filter, $select=false, $top=false, $skip=false, $orderby=false) |
|
235 | + public function getUsersByFilter($filter, $select = false, $top = false, $skip = false, $orderby = false) |
|
236 | 236 | { |
237 | 237 | return $this->convertDataToClass('group', 'SQLUser', $filter, $select, $top, $skip, $orderby); |
238 | 238 | } |
239 | 239 | |
240 | 240 | public function getPendingUserCount() |
241 | 241 | { |
242 | - if($this->pending === false) return 0; |
|
242 | + if ($this->pending === false) return 0; |
|
243 | 243 | $dataTable = $this->getPendingUserDataTable(); |
244 | - if($dataTable === null) return 0; |
|
244 | + if ($dataTable === null) return 0; |
|
245 | 245 | return $dataTable->count(); |
246 | 246 | } |
247 | 247 | |
@@ -249,26 +249,26 @@ discard block |
||
249 | 249 | { |
250 | 250 | $userDataTable = $this->getPendingUserDataTable(); |
251 | 251 | $fieldData = $filter->to_mongo_filter(); |
252 | - $firstFilter = new \Data\Filter('substringof(data,"'.implode($fieldData,' ').'")'); |
|
252 | + $firstFilter = new \Data\Filter('substringof(data,"'.implode($fieldData, ' ').'")'); |
|
253 | 253 | $users = $userDataTable->read($firstFilter, $select, $top, $skip, $orderby); |
254 | - if($users === false) |
|
254 | + if ($users === false) |
|
255 | 255 | { |
256 | 256 | return false; |
257 | 257 | } |
258 | 258 | $ret = array(); |
259 | 259 | $count = count($users); |
260 | - for($i = 0; $i < $count; $i++) |
|
260 | + for ($i = 0; $i < $count; $i++) |
|
261 | 261 | { |
262 | 262 | $user = new SQLPendingUser($users[$i], $userDataTable); |
263 | 263 | $err = false; |
264 | - foreach($fieldData as $field=>$data) |
|
264 | + foreach ($fieldData as $field=>$data) |
|
265 | 265 | { |
266 | - if(strcasecmp($user[$field], $data) !== 0) |
|
266 | + if (strcasecmp($user[$field], $data) !== 0) |
|
267 | 267 | { |
268 | 268 | $err = true; break; |
269 | 269 | } |
270 | 270 | } |
271 | - if(!$err) |
|
271 | + if (!$err) |
|
272 | 272 | { |
273 | 273 | array_push($ret, $user); |
274 | 274 | } |
@@ -276,22 +276,22 @@ discard block |
||
276 | 276 | return $ret; |
277 | 277 | } |
278 | 278 | |
279 | - public function getPendingUsersByFilter($filter, $select=false, $top=false, $skip=false, $orderby=false) |
|
279 | + public function getPendingUsersByFilter($filter, $select = false, $top = false, $skip = false, $orderby = false) |
|
280 | 280 | |
281 | 281 | { |
282 | - if($this->pending === false) return false; |
|
283 | - if($filter !== false && !$filter->contains('hash')) |
|
282 | + if ($this->pending === false) return false; |
|
283 | + if ($filter !== false && !$filter->contains('hash')) |
|
284 | 284 | { |
285 | 285 | return $this->searchPendingUsers($filter, $select, $top, $skip, $orderby); |
286 | 286 | } |
287 | 287 | $userDataTable = $this->getPendingUserDataTable(); |
288 | 288 | $users = $userDataTable->read($filter, $select, $top, $skip, $orderby); |
289 | - if($users === false) |
|
289 | + if ($users === false) |
|
290 | 290 | { |
291 | 291 | return false; |
292 | 292 | } |
293 | 293 | $count = count($users); |
294 | - for($i = 0; $i < $count; $i++) |
|
294 | + for ($i = 0; $i < $count; $i++) |
|
295 | 295 | { |
296 | 296 | $users[$i] = new SQLPendingUser($users[$i], $userDataTable); |
297 | 297 | } |
@@ -300,9 +300,9 @@ discard block |
||
300 | 300 | |
301 | 301 | public function createPendingUser($user) |
302 | 302 | { |
303 | - if($this->pending === false) return false; |
|
303 | + if ($this->pending === false) return false; |
|
304 | 304 | $userDataTable = $this->getPendingUserDataTable(); |
305 | - if(isset($user->password2)) |
|
305 | + if (isset($user->password2)) |
|
306 | 306 | { |
307 | 307 | unset($user->password2); |
308 | 308 | } |
@@ -310,10 +310,10 @@ discard block |
||
310 | 310 | $hash = hash('sha512', $json); |
311 | 311 | $array = array('hash'=>$hash, 'data'=>$json); |
312 | 312 | $ret = $userDataTable->create($array); |
313 | - if($ret !== false) |
|
313 | + if ($ret !== false) |
|
314 | 314 | { |
315 | 315 | $users = $this->getPendingUsersByFilter(new \Data\Filter("hash eq '$hash'")); |
316 | - if($users === false || !isset($users[0])) |
|
316 | + if ($users === false || !isset($users[0])) |
|
317 | 317 | { |
318 | 318 | throw new \Exception('Error retreiving user object after successful create!'); |
319 | 319 | } |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | public function getTempUserByHash($hash) |
326 | 326 | { |
327 | 327 | $users = $this->getPendingUsersByFilter(new \Data\Filter("hash eq '$hash'")); |
328 | - if($users === false || !isset($users[0])) |
|
328 | + if ($users === false || !isset($users[0])) |
|
329 | 329 | { |
330 | 330 | return false; |
331 | 331 | } |