@@ -162,8 +162,7 @@ |
||
162 | 162 | // We simply return and continue the login procedure (The normal way :)), |
163 | 163 | // and will disable all pages untill he has added a 2FA key. |
164 | 164 | return; |
165 | - } |
|
166 | - else |
|
165 | + } else |
|
167 | 166 | { |
168 | 167 | $redirect = $this->request->variable('redirect', "{$this->root_path}index.{$this->php_ext}"); |
169 | 168 | if ($event['admin']) |
@@ -73,13 +73,13 @@ discard block |
||
73 | 73 | */ |
74 | 74 | public function __construct(session_helper_interface $session_helper, user $user, request_interface $request, driver_interface $db, config $config, $php_ext, $root_path) |
75 | 75 | { |
76 | - $this->session_helper = $session_helper; |
|
77 | - $this->user = $user; |
|
76 | + $this->session_helper = $session_helper; |
|
77 | + $this->user = $user; |
|
78 | 78 | $this->request = $request; |
79 | - $this->config = $config; |
|
80 | - $this->db = $db; |
|
79 | + $this->config = $config; |
|
80 | + $this->db = $db; |
|
81 | 81 | $this->php_ext = $php_ext; |
82 | - $this->root_path = $root_path; |
|
82 | + $this->root_path = $root_path; |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | } |
121 | 121 | if ($this->user->data['is_bot'] == false && $this->user->data['user_id'] != ANONYMOUS && $this->session_helper->isTfaRequired($this->user->data['user_id'], false, $this->user->data) && !$this->session_helper->isTfaRegistered($this->user->data['user_id'])) |
122 | 122 | { |
123 | - $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " WHERE module_langname = 'UCP_TFA' OR module_langname = 'UCP_TFA_MANAGE'"; |
|
123 | + $sql = 'SELECT module_id FROM '.MODULES_TABLE." WHERE module_langname = 'UCP_TFA' OR module_langname = 'UCP_TFA_MANAGE'"; |
|
124 | 124 | $result = $this->db->sql_query($sql, 3600); |
125 | 125 | $allowed_i = array(); |
126 | 126 | |
@@ -132,13 +132,13 @@ discard block |
||
132 | 132 | $ucp_mode = '-paul999-tfa-ucp-tfa_module'; |
133 | 133 | $allowed_i[] = $ucp_mode; |
134 | 134 | |
135 | - if ($this->user->page['page_name'] === 'ucp.' . $this->php_ext && in_array($this->request->variable('i', ''), $allowed_i)) |
|
135 | + if ($this->user->page['page_name'] === 'ucp.'.$this->php_ext && in_array($this->request->variable('i', ''), $allowed_i)) |
|
136 | 136 | { |
137 | 137 | return; // We are at our UCP page, so skip any other checks. This page is always available |
138 | 138 | } |
139 | 139 | $this->user->add_lang_ext('paul999/tfa', 'common'); |
140 | 140 | $url = append_sid("{$this->root_path}ucp.{$this->php_ext}", "i={$ucp_mode}"); |
141 | - trigger_error($this->user->lang('TFA_REQUIRED_KEY_MISSING', '<a href="' . $url . '">', '</a>'), E_USER_WARNING); |
|
141 | + trigger_error($this->user->lang('TFA_REQUIRED_KEY_MISSING', '<a href="'.$url.'">', '</a>'), E_USER_WARNING); |
|
142 | 142 | |
143 | 143 | } |
144 | 144 | } |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | { |
17 | 17 | return array( |
18 | 18 | 'add_tables' => array( |
19 | - $this->table_prefix . 'tfa_registration' => array( |
|
19 | + $this->table_prefix.'tfa_registration' => array( |
|
20 | 20 | 'COLUMNS' => array( |
21 | 21 | 'registration_id' => array('UINT', null, 'auto_increment'), |
22 | 22 | 'user_id' => array('UINT', 0), |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | { |
41 | 41 | return array( |
42 | 42 | 'drop_tables' => array( |
43 | - $this->table_prefix . 'tfa_registration', |
|
43 | + $this->table_prefix.'tfa_registration', |
|
44 | 44 | ), |
45 | 45 | ); |
46 | 46 | } |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | { |
25 | 25 | return array( |
26 | 26 | 'add_columns' => array( |
27 | - $this->table_prefix . 'sessions' => array( |
|
27 | + $this->table_prefix.'sessions' => array( |
|
28 | 28 | 'u2f_request' => array('TEXT', null), |
29 | 29 | ), |
30 | 30 | ), |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | { |
36 | 36 | return array( |
37 | 37 | 'drop_columns' => array( |
38 | - $this->table_prefix . 'sessions' => array( |
|
38 | + $this->table_prefix.'sessions' => array( |
|
39 | 39 | 'u2f_request', |
40 | 40 | ), |
41 | 41 | ), |
@@ -108,18 +108,15 @@ discard block |
||
108 | 108 | if ($module->can_register()) |
109 | 109 | { |
110 | 110 | $this->tpl_name = $module->register_start(); |
111 | - } |
|
112 | - else |
|
111 | + } else |
|
113 | 112 | { |
114 | 113 | $error[] = 'TFA_MODULE_NO_REGISTER'; |
115 | 114 | } |
116 | - } |
|
117 | - else |
|
115 | + } else |
|
118 | 116 | { |
119 | 117 | $error[] = $this->user->lang('TFA_MODULE_NOT_FOUND', $class); |
120 | 118 | } |
121 | - } |
|
122 | - catch (\Exception $e) |
|
119 | + } catch (\Exception $e) |
|
123 | 120 | { |
124 | 121 | $error[] = $e->getMessage(); |
125 | 122 | } |
@@ -151,8 +148,7 @@ discard block |
||
151 | 148 | if (!check_form_key('ucp_tfa_keys')) |
152 | 149 | { |
153 | 150 | $error[] = 'FORM_INVALID'; |
154 | - } |
|
155 | - else |
|
151 | + } else |
|
156 | 152 | { |
157 | 153 | if ($this->request->variable('md', false, false, \phpbb\request\request_interface::POST)) |
158 | 154 | { |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | { |
102 | 102 | $module->register(); |
103 | 103 | meta_refresh(3, $this->u_action); |
104 | - $message = $this->user->lang('TFA_KEY_ADDED') . '<br /><br />' . $this->user->lang('RETURN_UCP', '<a href="' . $this->u_action . '">', '</a>'); |
|
104 | + $message = $this->user->lang('TFA_KEY_ADDED').'<br /><br />'.$this->user->lang('RETURN_UCP', '<a href="'.$this->u_action.'">', '</a>'); |
|
105 | 105 | trigger_error($message); |
106 | 106 | } |
107 | 107 | if ($module->can_register()) |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | } |
228 | 228 | } |
229 | 229 | meta_refresh(3, $this->u_action); |
230 | - $message = $this->user->lang('TFA_KEYS_DELETED') . '<br /><br />' . $this->user->lang('RETURN_UCP', '<a href="' . $this->u_action . '">', '</a>'); |
|
230 | + $message = $this->user->lang('TFA_KEYS_DELETED').'<br /><br />'.$this->user->lang('RETURN_UCP', '<a href="'.$this->u_action.'">', '</a>'); |
|
231 | 231 | trigger_error($message); |
232 | 232 | } |
233 | 233 | } |
@@ -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 | } |
@@ -60,11 +60,11 @@ discard block |
||
60 | 60 | $this->user = $user; |
61 | 61 | $this->request = $request; |
62 | 62 | $this->template = $template; |
63 | - $this->root_path= $root_path; |
|
63 | + $this->root_path = $root_path; |
|
64 | 64 | |
65 | - $this->registration_table = $registration_table; |
|
65 | + $this->registration_table = $registration_table; |
|
66 | 66 | |
67 | - $this->u2f = new \paul999\u2f\U2F('https://' . $this->request->server('HTTP_HOST')); |
|
67 | + $this->u2f = new \paul999\u2f\U2F('https://'.$this->request->server('HTTP_HOST')); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | /** |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | */ |
111 | 111 | public function is_potentially_usable($user_id = false) |
112 | 112 | { |
113 | - $browsercap = new Browscap($this->root_path . 'cache/'); |
|
113 | + $browsercap = new Browscap($this->root_path.'cache/'); |
|
114 | 114 | $info = $browsercap->getBrowser($this->request->server('HTTP_USER_AGENT')); |
115 | 115 | return strtolower($info->Browser) === 'chrome' && $this->is_ssl(); |
116 | 116 | } |
@@ -192,9 +192,9 @@ discard block |
||
192 | 192 | try |
193 | 193 | { |
194 | 194 | $sql = 'SELECT u2f_request |
195 | - FROM ' . SESSIONS_TABLE . " |
|
195 | + FROM ' . SESSIONS_TABLE." |
|
196 | 196 | WHERE |
197 | - session_id = '" . $this->db->sql_escape($this->user->data['session_id']) . "' AND |
|
197 | + session_id = '" . $this->db->sql_escape($this->user->data['session_id'])."' AND |
|
198 | 198 | session_user_id = " . (int) $this->user->data['user_id']; |
199 | 199 | $result = $this->db->sql_query($sql); |
200 | 200 | $row = $this->db->sql_fetchrow($result); |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | 'last_used' => time(), |
225 | 225 | ); |
226 | 226 | |
227 | - $sql = 'UPDATE ' . $this->registration_table . ' SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' WHERE registration_id = ' . (int) $reg->getId(); |
|
227 | + $sql = 'UPDATE '.$this->registration_table.' SET '.$this->db->sql_build_array('UPDATE', $sql_ary).' WHERE registration_id = '.(int) $reg->getId(); |
|
228 | 228 | $this->db->sql_query($sql); |
229 | 229 | |
230 | 230 | return true; |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | } |
236 | 236 | catch (\InvalidArgumentException $invalid) |
237 | 237 | { |
238 | - throw new http_exception(400, 'TFA_SOMETHING_WENT_WRONG' . '<br />' . $invalid->getMessage(), array(), $invalid); |
|
238 | + throw new http_exception(400, 'TFA_SOMETHING_WENT_WRONG'.'<br />'.$invalid->getMessage(), array(), $invalid); |
|
239 | 239 | } |
240 | 240 | return false; |
241 | 241 | } |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | 'last_used' => time(), |
321 | 321 | ); |
322 | 322 | |
323 | - $sql = 'INSERT INTO ' . $this->registration_table . ' ' . $this->db->sql_build_array('INSERT', $sql_ary); |
|
323 | + $sql = 'INSERT INTO '.$this->registration_table.' '.$this->db->sql_build_array('INSERT', $sql_ary); |
|
324 | 324 | $this->db->sql_query($sql); |
325 | 325 | |
326 | 326 | $sql_ary = array( |
@@ -352,8 +352,8 @@ discard block |
||
352 | 352 | */ |
353 | 353 | public function delete($key) |
354 | 354 | { |
355 | - $sql = 'DELETE FROM ' . $this->registration_table . ' |
|
356 | - WHERE user_id = ' . (int) $this->user->data['user_id'] . ' |
|
355 | + $sql = 'DELETE FROM '.$this->registration_table.' |
|
356 | + WHERE user_id = ' . (int) $this->user->data['user_id'].' |
|
357 | 357 | AND registration_id =' . (int) $key; |
358 | 358 | |
359 | 359 | $this->db->sql_query($sql); |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | */ |
396 | 396 | private function getRegistrations($user_id) |
397 | 397 | { |
398 | - $sql = 'SELECT * FROM ' . $this->registration_table . ' WHERE user_id = ' . (int) $user_id; |
|
398 | + $sql = 'SELECT * FROM '.$this->registration_table.' WHERE user_id = '.(int) $user_id; |
|
399 | 399 | $result = $this->db->sql_query($sql); |
400 | 400 | $rows = array(); |
401 | 401 | |
@@ -483,9 +483,9 @@ discard block |
||
483 | 483 | */ |
484 | 484 | private function update_session($sql_ary) |
485 | 485 | { |
486 | - $sql = 'UPDATE ' . SESSIONS_TABLE . ' SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . " |
|
486 | + $sql = 'UPDATE '.SESSIONS_TABLE.' SET '.$this->db->sql_build_array('UPDATE', $sql_ary)." |
|
487 | 487 | WHERE |
488 | - session_id = '" . $this->db->sql_escape($this->user->data['session_id']) . "' AND |
|
488 | + session_id = '" . $this->db->sql_escape($this->user->data['session_id'])."' AND |
|
489 | 489 | session_user_id = " . (int) $this->user->data['user_id']; |
490 | 490 | $this->db->sql_query($sql); |
491 | 491 |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | { |
25 | 25 | return array( |
26 | 26 | 'add_columns' => array( |
27 | - $this->table_prefix . 'sessions' => array( |
|
27 | + $this->table_prefix.'sessions' => array( |
|
28 | 28 | 'u2f_request' => array('TEXT', null), |
29 | 29 | ), |
30 | 30 | ), |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | { |
36 | 36 | return array( |
37 | 37 | 'drop_columns' => array( |
38 | - $this->table_prefix . 'sessions' => array( |
|
38 | + $this->table_prefix.'sessions' => array( |
|
39 | 39 | 'u2f_request', |
40 | 40 | ), |
41 | 41 | ), |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | { |
17 | 17 | return array( |
18 | 18 | 'add_tables' => array( |
19 | - $this->table_prefix . 'tfa_back_reg' => array( |
|
19 | + $this->table_prefix.'tfa_back_reg' => array( |
|
20 | 20 | 'COLUMNS' => array( |
21 | 21 | 'registration_id' => array('UINT', null, 'auto_increment'), |
22 | 22 | 'user_id' => array('UINT', 0), |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | { |
39 | 39 | return array( |
40 | 40 | 'drop_tables' => array( |
41 | - $this->table_prefix . 'tfa_back_reg', |
|
41 | + $this->table_prefix.'tfa_back_reg', |
|
42 | 42 | ), |
43 | 43 | ); |
44 | 44 | } |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | { |
17 | 17 | return array( |
18 | 18 | 'add_tables' => array( |
19 | - $this->table_prefix . 'tfa_otp_reg' => array( |
|
19 | + $this->table_prefix.'tfa_otp_reg' => array( |
|
20 | 20 | 'COLUMNS' => array( |
21 | 21 | 'registration_id' => array('UINT', null, 'auto_increment'), |
22 | 22 | 'user_id' => array('UINT', 0), |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | { |
38 | 38 | return array( |
39 | 39 | 'drop_tables' => array( |
40 | - $this->table_prefix . 'tfa_otp_reg', |
|
40 | + $this->table_prefix.'tfa_otp_reg', |
|
41 | 41 | ), |
42 | 42 | ); |
43 | 43 | } |
@@ -87,13 +87,13 @@ discard block |
||
87 | 87 | */ |
88 | 88 | public function __construct(driver_interface $db, config $config, user $user, service_collection $modules, template $template, helper $controller_helper, $registration_table, $user_table) |
89 | 89 | { |
90 | - $this->db = $db; |
|
91 | - $this->user = $user; |
|
92 | - $this->config = $config; |
|
93 | - $this->template = $template; |
|
90 | + $this->db = $db; |
|
91 | + $this->user = $user; |
|
92 | + $this->config = $config; |
|
93 | + $this->template = $template; |
|
94 | 94 | $this->controller_helper = $controller_helper; |
95 | 95 | $this->registration_table = $registration_table; |
96 | - $this->user_table = $user_table; |
|
96 | + $this->user_table = $user_table; |
|
97 | 97 | |
98 | 98 | $this->validateModules($modules); |
99 | 99 | |
@@ -257,9 +257,9 @@ discard block |
||
257 | 257 | 'tfa_random' => $random, |
258 | 258 | 'tfa_uid' => $user_id, |
259 | 259 | ); |
260 | - $sql = 'UPDATE ' . SESSIONS_TABLE . ' SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . " |
|
260 | + $sql = 'UPDATE '.SESSIONS_TABLE.' SET '.$this->db->sql_build_array('UPDATE', $sql_ary)." |
|
261 | 261 | WHERE |
262 | - session_id = '" . $this->db->sql_escape($this->user->data['session_id']) . "' AND |
|
262 | + session_id = '" . $this->db->sql_escape($this->user->data['session_id'])."' AND |
|
263 | 263 | session_user_id = " . (int) $this->user->data['user_id']; |
264 | 264 | $this->db->sql_query($sql); |
265 | 265 | |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | { |
288 | 288 | if (empty($userdata)) |
289 | 289 | { |
290 | - $sql = 'SELECT * FROM ' . $this->user_table . ' WHERE user_id = ' . (int) $user_id; |
|
290 | + $sql = 'SELECT * FROM '.$this->user_table.' WHERE user_id = '.(int) $user_id; |
|
291 | 291 | $result = $this->db->sql_query($sql); |
292 | 292 | $userdata = $this->db->sql_fetchrow($result); |
293 | 293 | $this->db->sql_freeresult($result); |