@@ -86,7 +86,7 @@ |
||
| 86 | 86 | * |
| 87 | 87 | * Do not return false in case a specific user disabeld this module, |
| 88 | 88 | * OR if the user is unable to use this specific module. |
| 89 | - * @return boolean |
|
| 89 | + * @return boolean|null |
|
| 90 | 90 | */ |
| 91 | 91 | public function is_enabled() |
| 92 | 92 | { |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | $this->request = $request; |
| 76 | 76 | $this->template = $template; |
| 77 | 77 | |
| 78 | - $this->registration_table = $registration_table; |
|
| 78 | + $this->registration_table = $registration_table; |
|
| 79 | 79 | |
| 80 | 80 | $this->u2f = new \paul999\u2f\U2F('https://' . $this->request->server('HTTP_HOST')); |
| 81 | 81 | } |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | { |
| 202 | 202 | $sql = 'SELECT u2f_request FROM ' . SESSIONS_TABLE . ' WHERE |
| 203 | 203 | session_id = \'' . $this->db->sql_escape($this->user->data['session_id']) . '\' AND |
| 204 | - session_user_id = ' . (int)$this->user->data['user_id']; |
|
| 204 | + session_user_id = ' . (int) $this->user->data['user_id']; |
|
| 205 | 205 | $result = $this->db->sql_query($sql); |
| 206 | 206 | $row = $this->db->sql_fetchrow($result); |
| 207 | 207 | $this->db->sql_freeresult($result); |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | 'last_used' => time(), |
| 231 | 231 | ); |
| 232 | 232 | |
| 233 | - $sql = 'UPDATE ' . $this->registration_table . ' SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' WHERE registration_id = ' . (int)$reg->id; |
|
| 233 | + $sql = 'UPDATE ' . $this->registration_table . ' SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' WHERE registration_id = ' . (int) $reg->id; |
|
| 234 | 234 | $this->db->sql_query($sql); |
| 235 | 235 | } |
| 236 | 236 | catch (U2fError $error) |
@@ -348,13 +348,13 @@ discard block |
||
| 348 | 348 | 'LAST_USED' => $this->user->format_date($row['last_used']), |
| 349 | 349 | )); |
| 350 | 350 | |
| 351 | - $reg = new registration_helper(); |
|
| 351 | + $reg = new registration_helper(); |
|
| 352 | 352 | $reg->setCounter($row['counter']); |
| 353 | 353 | $reg->setCertificate($row['certificate']); |
| 354 | 354 | $reg->setKeyHandle($row['key_handle']); |
| 355 | 355 | $reg->setPublicKey($row['public_key']); |
| 356 | - $reg->id = $row['registration_id']; |
|
| 357 | - $this->reg_data = $reg; |
|
| 356 | + $reg->id = $row['registration_id']; |
|
| 357 | + $this->reg_data = $reg; |
|
| 358 | 358 | } |
| 359 | 359 | $this->db->sql_freeresult($result); |
| 360 | 360 | } |
@@ -371,7 +371,7 @@ discard block |
||
| 371 | 371 | { |
| 372 | 372 | $sql_where = $this->db->sql_in_set('registration_id', $data['keys']); |
| 373 | 373 | $sql = 'DELETE FROM ' . $this->registration_table . ' |
| 374 | - WHERE user_id = ' . (int)$this->user->data['user_id'] . ' |
|
| 374 | + WHERE user_id = ' . (int) $this->user->data['user_id'] . ' |
|
| 375 | 375 | AND ' . $sql_where; |
| 376 | 376 | |
| 377 | 377 | $this->db->sql_query($sql); |
@@ -391,13 +391,13 @@ discard block |
||
| 391 | 391 | |
| 392 | 392 | while ($row = $this->db->sql_fetchrow($result)) |
| 393 | 393 | { |
| 394 | - $reg = new registration_helper(); |
|
| 394 | + $reg = new registration_helper(); |
|
| 395 | 395 | $reg->setCounter($row['counter']); |
| 396 | 396 | $reg->setCertificate($row['certificate']); |
| 397 | 397 | $reg->setKeyHandle($row['key_handle']); |
| 398 | 398 | $reg->setPublicKey($row['public_key']); |
| 399 | - $reg->id = $row['registration_id']; |
|
| 400 | - $rows[] = $reg; |
|
| 399 | + $reg->id = $row['registration_id']; |
|
| 400 | + $rows[] = $reg; |
|
| 401 | 401 | } |
| 402 | 402 | |
| 403 | 403 | $this->db->sql_freeresult($result); |
@@ -215,10 +215,12 @@ discard block |
||
| 215 | 215 | |
| 216 | 216 | if (property_exists($response, 'errorCode')) |
| 217 | 217 | { |
| 218 | - if ($response->errorCode == 4) // errorCode 4 means that this device wasn't registered |
|
| 218 | + if ($response->errorCode == 4) { |
|
| 219 | + // errorCode 4 means that this device wasn't registered |
|
| 219 | 220 | { |
| 220 | 221 | throw new AccessDeniedHttpException($this->user->lang('TFA_NOT_REGISTERED')); |
| 221 | 222 | } |
| 223 | + } |
|
| 222 | 224 | throw new BadRequestHttpException($this->user->lang('TFA_SOMETHING_WENT_WRONG')); |
| 223 | 225 | } |
| 224 | 226 | $result = new AuthenticationResponse($response->signatureData, $response->clientData, $response->keyHandle, $response->errorCode); |
@@ -232,12 +234,10 @@ discard block |
||
| 232 | 234 | |
| 233 | 235 | $sql = 'UPDATE ' . $this->registration_table . ' SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' WHERE registration_id = ' . (int)$reg->id; |
| 234 | 236 | $this->db->sql_query($sql); |
| 235 | - } |
|
| 236 | - catch (U2fError $error) |
|
| 237 | + } catch (U2fError $error) |
|
| 237 | 238 | { |
| 238 | 239 | $this->createError($error); |
| 239 | - } |
|
| 240 | - catch (\InvalidArgumentException $invalid) |
|
| 240 | + } catch (\InvalidArgumentException $invalid) |
|
| 241 | 241 | { |
| 242 | 242 | throw new BadRequestHttpException($this->user->lang('TFA_SOMETHING_WENT_WRONG') . '<br />' . $invalid->getMessage(), $invalid); |
| 243 | 243 | } |
@@ -274,8 +274,7 @@ discard block |
||
| 274 | 274 | if ($count == 0) |
| 275 | 275 | { |
| 276 | 276 | trigger_error('TFA_UNABLE_TO_UPDATE_SESSION'); |
| 277 | - } |
|
| 278 | - else if ($count > 1) |
|
| 277 | + } else if ($count > 1) |
|
| 279 | 278 | { |
| 280 | 279 | // Reset sessions table. We had multiple sessions with same ID!!! |
| 281 | 280 | $sql_ary['u2f_request'] = ''; |
@@ -319,8 +318,7 @@ discard block |
||
| 319 | 318 | ); |
| 320 | 319 | |
| 321 | 320 | $this->update_session($sql_ary); |
| 322 | - } |
|
| 323 | - catch (U2fError $err) |
|
| 321 | + } catch (U2fError $err) |
|
| 324 | 322 | { |
| 325 | 323 | $this->createError($err); |
| 326 | 324 | } |
@@ -101,13 +101,11 @@ discard block |
||
| 101 | 101 | meta_refresh(3, $this->u_action); |
| 102 | 102 | $message = $this->user->lang['TFA_KEY_ADDED'] . '<br /><br />' . sprintf($this->user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>'); |
| 103 | 103 | trigger_error($message); |
| 104 | - } |
|
| 105 | - else |
|
| 104 | + } else |
|
| 106 | 105 | { |
| 107 | 106 | $error[] = $this->user->lang('TFA_MODULE_NOT_FOUND', $class); |
| 108 | 107 | } |
| 109 | - } |
|
| 110 | - catch (\Exception $e) |
|
| 108 | + } catch (\Exception $e) |
|
| 111 | 109 | { |
| 112 | 110 | $error[] = $e->getMessage(); |
| 113 | 111 | } |
@@ -130,8 +128,7 @@ discard block |
||
| 130 | 128 | if (!check_form_key('ucp_tfa_keys')) |
| 131 | 129 | { |
| 132 | 130 | $error[] = 'FORM_INVALID'; |
| 133 | - } |
|
| 134 | - else |
|
| 131 | + } else |
|
| 135 | 132 | { |
| 136 | 133 | switch ($mode) |
| 137 | 134 | { |