@@ -78,11 +78,11 @@ discard block |
||
| 78 | 78 | $this->user = $user; |
| 79 | 79 | $this->request = $request; |
| 80 | 80 | $this->template = $template; |
| 81 | - $this->root_path= $root_path; |
|
| 81 | + $this->root_path = $root_path; |
|
| 82 | 82 | |
| 83 | - $this->registration_table = $registration_table; |
|
| 83 | + $this->registration_table = $registration_table; |
|
| 84 | 84 | |
| 85 | - $this->u2f = new \paul999\u2f\U2F('https://' . $this->request->server('HTTP_HOST')); |
|
| 85 | + $this->u2f = new \paul999\u2f\U2F('https://'.$this->request->server('HTTP_HOST')); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | /** |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | return false; |
| 116 | 116 | } |
| 117 | 117 | $sql = 'SELECT COUNT(registration_id) as reg_id |
| 118 | - FROM ' . $this->registration_table . ' |
|
| 118 | + FROM ' . $this->registration_table.' |
|
| 119 | 119 | WHERE |
| 120 | 120 | user_id = ' . (int) $user_id; |
| 121 | 121 | $result = $this->db->sql_query($sql); |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | */ |
| 137 | 137 | public function is_potentially_usable($user_id = false) |
| 138 | 138 | { |
| 139 | - $browsercap = new Browscap($this->root_path . 'cache/'); |
|
| 139 | + $browsercap = new Browscap($this->root_path.'cache/'); |
|
| 140 | 140 | $info = $browsercap->getBrowser($this->request->server('HTTP_USER_AGENT')); |
| 141 | 141 | return strtolower($info->Browser) === 'chrome' && $this->is_ssl(); |
| 142 | 142 | } |
@@ -217,9 +217,9 @@ discard block |
||
| 217 | 217 | try |
| 218 | 218 | { |
| 219 | 219 | $sql = 'SELECT u2f_request |
| 220 | - FROM ' . SESSIONS_TABLE . ' |
|
| 220 | + FROM ' . SESSIONS_TABLE.' |
|
| 221 | 221 | WHERE |
| 222 | - session_id = \'' . $this->db->sql_escape($this->user->data['session_id']) . '\' AND |
|
| 222 | + session_id = \'' . $this->db->sql_escape($this->user->data['session_id']).'\' AND |
|
| 223 | 223 | session_user_id = ' . (int) $this->user->data['user_id']; |
| 224 | 224 | $result = $this->db->sql_query($sql); |
| 225 | 225 | $row = $this->db->sql_fetchrow($result); |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | 'last_used' => time(), |
| 250 | 250 | ); |
| 251 | 251 | |
| 252 | - $sql = 'UPDATE ' . $this->registration_table . ' SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' WHERE registration_id = ' . (int) $reg->getId(); |
|
| 252 | + $sql = 'UPDATE '.$this->registration_table.' SET '.$this->db->sql_build_array('UPDATE', $sql_ary).' WHERE registration_id = '.(int) $reg->getId(); |
|
| 253 | 253 | $this->db->sql_query($sql); |
| 254 | 254 | } |
| 255 | 255 | catch (U2fError $error) |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | } |
| 259 | 259 | catch (\InvalidArgumentException $invalid) |
| 260 | 260 | { |
| 261 | - throw new BadRequestHttpException($this->user->lang('TFA_SOMETHING_WENT_WRONG') . '<br />' . $invalid->getMessage(), $invalid); |
|
| 261 | + throw new BadRequestHttpException($this->user->lang('TFA_SOMETHING_WENT_WRONG').'<br />'.$invalid->getMessage(), $invalid); |
|
| 262 | 262 | } |
| 263 | 263 | } |
| 264 | 264 | |
@@ -343,7 +343,7 @@ discard block |
||
| 343 | 343 | 'last_used' => time(), |
| 344 | 344 | ); |
| 345 | 345 | |
| 346 | - $sql = 'INSERT INTO ' . $this->registration_table . ' ' . $this->db->sql_build_array('INSERT', $sql_ary); |
|
| 346 | + $sql = 'INSERT INTO '.$this->registration_table.' '.$this->db->sql_build_array('INSERT', $sql_ary); |
|
| 347 | 347 | $this->db->sql_query($sql); |
| 348 | 348 | |
| 349 | 349 | $sql_ary = array( |
@@ -365,8 +365,8 @@ discard block |
||
| 365 | 365 | public function show_ucp() |
| 366 | 366 | { |
| 367 | 367 | $sql = 'SELECT * |
| 368 | - FROM ' . $this->registration_table . ' |
|
| 369 | - WHERE user_id = ' . (int) $this->user->data['user_id'] . ' |
|
| 368 | + FROM ' . $this->registration_table.' |
|
| 369 | + WHERE user_id = ' . (int) $this->user->data['user_id'].' |
|
| 370 | 370 | ORDER BY registration_id ASC'; |
| 371 | 371 | |
| 372 | 372 | $result = $this->db->sql_query($sql); |
@@ -391,8 +391,8 @@ discard block |
||
| 391 | 391 | */ |
| 392 | 392 | public function delete($key) |
| 393 | 393 | { |
| 394 | - $sql = 'DELETE FROM ' . $this->registration_table . ' |
|
| 395 | - WHERE user_id = ' . (int) $this->user->data['user_id'] . ' |
|
| 394 | + $sql = 'DELETE FROM '.$this->registration_table.' |
|
| 395 | + WHERE user_id = ' . (int) $this->user->data['user_id'].' |
|
| 396 | 396 | AND registration_id =' . (int) $key; |
| 397 | 397 | |
| 398 | 398 | $this->db->sql_query($sql); |
@@ -434,7 +434,7 @@ discard block |
||
| 434 | 434 | */ |
| 435 | 435 | private function getRegistrations($user_id) |
| 436 | 436 | { |
| 437 | - $sql = 'SELECT * FROM ' . $this->registration_table . ' WHERE user_id = ' . (int) $user_id; |
|
| 437 | + $sql = 'SELECT * FROM '.$this->registration_table.' WHERE user_id = '.(int) $user_id; |
|
| 438 | 438 | $result = $this->db->sql_query($sql); |
| 439 | 439 | $rows = array(); |
| 440 | 440 | |
@@ -522,9 +522,9 @@ discard block |
||
| 522 | 522 | */ |
| 523 | 523 | private function update_session($sql_ary) |
| 524 | 524 | { |
| 525 | - $sql = 'UPDATE ' . SESSIONS_TABLE . ' SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' |
|
| 525 | + $sql = 'UPDATE '.SESSIONS_TABLE.' SET '.$this->db->sql_build_array('UPDATE', $sql_ary).' |
|
| 526 | 526 | WHERE |
| 527 | - session_id = \'' . $this->db->sql_escape($this->user->data['session_id']) . '\' AND |
|
| 527 | + session_id = \'' . $this->db->sql_escape($this->user->data['session_id']).'\' AND |
|
| 528 | 528 | session_user_id = ' . (int) $this->user->data['user_id']; |
| 529 | 529 | $this->db->sql_query($sql); |
| 530 | 530 | |
@@ -152,8 +152,7 @@ discard block |
||
| 152 | 152 | if (!empty($secure)) |
| 153 | 153 | { |
| 154 | 154 | return 'on' == strtolower($secure) || '1' == $secure; |
| 155 | - } |
|
| 156 | - else if ('443' == $this->request->server('SERVER_PORT')) |
|
| 155 | + } else if ('443' == $this->request->server('SERVER_PORT')) |
|
| 157 | 156 | { |
| 158 | 157 | return true; |
| 159 | 158 | } |
@@ -234,10 +233,12 @@ discard block |
||
| 234 | 233 | |
| 235 | 234 | if (property_exists($response, 'errorCode')) |
| 236 | 235 | { |
| 237 | - if ($response->errorCode == 4) // errorCode 4 means that this device wasn't registered |
|
| 236 | + if ($response->errorCode == 4) { |
|
| 237 | + // errorCode 4 means that this device wasn't registered |
|
| 238 | 238 | { |
| 239 | 239 | throw new AccessDeniedHttpException($this->user->lang('TFA_NOT_REGISTERED')); |
| 240 | 240 | } |
| 241 | + } |
|
| 241 | 242 | throw new BadRequestHttpException($this->user->lang('TFA_SOMETHING_WENT_WRONG')); |
| 242 | 243 | } |
| 243 | 244 | $result = new AuthenticationResponse($response->signatureData, $response->clientData, $response->keyHandle); // Do not need to include errorCode, as we already handled it. |
@@ -251,12 +252,10 @@ discard block |
||
| 251 | 252 | |
| 252 | 253 | $sql = 'UPDATE ' . $this->registration_table . ' SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' WHERE registration_id = ' . (int) $reg->getId(); |
| 253 | 254 | $this->db->sql_query($sql); |
| 254 | - } |
|
| 255 | - catch (U2fError $error) |
|
| 255 | + } catch (U2fError $error) |
|
| 256 | 256 | { |
| 257 | 257 | $this->createError($error); |
| 258 | - } |
|
| 259 | - catch (\InvalidArgumentException $invalid) |
|
| 258 | + } catch (\InvalidArgumentException $invalid) |
|
| 260 | 259 | { |
| 261 | 260 | throw new BadRequestHttpException($this->user->lang('TFA_SOMETHING_WENT_WRONG') . '<br />' . $invalid->getMessage(), $invalid); |
| 262 | 261 | } |
@@ -351,8 +350,7 @@ discard block |
||
| 351 | 350 | ); |
| 352 | 351 | |
| 353 | 352 | $this->update_session($sql_ary); |
| 354 | - } |
|
| 355 | - catch (U2fError $err) |
|
| 353 | + } catch (U2fError $err) |
|
| 356 | 354 | { |
| 357 | 355 | $this->createError($err); |
| 358 | 356 | } |