@@ -111,18 +111,15 @@ discard block |
||
| 111 | 111 | 'S_UCP_ACTION' => $this->u_action, |
| 112 | 112 | )); |
| 113 | 113 | $this->tpl_name = $module->register_start(); |
| 114 | - } |
|
| 115 | - else |
|
| 114 | + } else |
|
| 116 | 115 | { |
| 117 | 116 | $error[] = 'TFA_MODULE_NO_REGISTER'; |
| 118 | 117 | } |
| 119 | - } |
|
| 120 | - else |
|
| 118 | + } else |
|
| 121 | 119 | { |
| 122 | 120 | $error[] = $this->user->lang('TFA_MODULE_NOT_FOUND', $class); |
| 123 | 121 | } |
| 124 | - } |
|
| 125 | - catch (\Exception $e) |
|
| 122 | + } catch (\Exception $e) |
|
| 126 | 123 | { |
| 127 | 124 | $error[] = $e->getMessage(); |
| 128 | 125 | } |
@@ -154,8 +151,7 @@ discard block |
||
| 154 | 151 | if (!check_form_key('ucp_tfa_keys')) |
| 155 | 152 | { |
| 156 | 153 | $error[] = 'FORM_INVALID'; |
| 157 | - } |
|
| 158 | - else |
|
| 154 | + } else |
|
| 159 | 155 | { |
| 160 | 156 | $this->delete_keys(); |
| 161 | 157 | } |
@@ -123,8 +123,7 @@ discard block |
||
| 123 | 123 | if (!empty($secure)) |
| 124 | 124 | { |
| 125 | 125 | return 'on' === strtolower($secure) || '1' == $secure; |
| 126 | - } |
|
| 127 | - else if ('443' == $this->request->server('SERVER_PORT')) |
|
| 126 | + } else if ('443' == $this->request->server('SERVER_PORT')) |
|
| 128 | 127 | { |
| 129 | 128 | return true; |
| 130 | 129 | } |
@@ -207,10 +206,12 @@ discard block |
||
| 207 | 206 | |
| 208 | 207 | if (property_exists($response, 'errorCode')) |
| 209 | 208 | { |
| 210 | - if ($response->errorCode == 4) // errorCode 4 means that this device wasn't registered |
|
| 209 | + if ($response->errorCode == 4) { |
|
| 210 | + // errorCode 4 means that this device wasn't registered |
|
| 211 | 211 | { |
| 212 | 212 | throw new http_exception(403, 'TFA_NOT_REGISTERED'); |
| 213 | 213 | } |
| 214 | + } |
|
| 214 | 215 | throw new http_exception(400, 'TFA_SOMETHING_WENT_WRONG'); |
| 215 | 216 | } |
| 216 | 217 | $result = new AuthenticationResponse($response->signatureData, $response->clientData, $response->keyHandle); // Do not need to include errorCode, as we already handled it. |
@@ -226,12 +227,10 @@ discard block |
||
| 226 | 227 | $this->db->sql_query($sql); |
| 227 | 228 | |
| 228 | 229 | return true; |
| 229 | - } |
|
| 230 | - catch (U2fError $error) |
|
| 230 | + } catch (U2fError $error) |
|
| 231 | 231 | { |
| 232 | 232 | $this->createError($error); |
| 233 | - } |
|
| 234 | - catch (\InvalidArgumentException $invalid) |
|
| 233 | + } catch (\InvalidArgumentException $invalid) |
|
| 235 | 234 | { |
| 236 | 235 | throw new http_exception(400, 'TFA_SOMETHING_WENT_WRONG'); |
| 237 | 236 | } |
@@ -326,8 +325,7 @@ discard block |
||
| 326 | 325 | ); |
| 327 | 326 | |
| 328 | 327 | $this->update_session($sql_ary); |
| 329 | - } |
|
| 330 | - catch (U2fError $err) |
|
| 328 | + } catch (U2fError $err) |
|
| 331 | 329 | { |
| 332 | 330 | $this->createError($err); |
| 333 | 331 | } |
@@ -199,8 +199,7 @@ |
||
| 199 | 199 | // We simply return and continue the login procedure (The normal way :)), |
| 200 | 200 | // and will disable all pages until he has added a 2FA key. |
| 201 | 201 | return $event; |
| 202 | - } |
|
| 203 | - else |
|
| 202 | + } else |
|
| 204 | 203 | { |
| 205 | 204 | $this->session_helper->generate_page($event['login']['user_row']['user_id'], $event['admin'], $event['autologin'], !$this->request->is_set_post('viewonline'), $this->request->variable('redirect', '')); |
| 206 | 205 | } |
@@ -162,8 +162,7 @@ discard block |
||
| 162 | 162 | $this->template->assign_var('S_ERROR', $this->user->lang('TFA_INCORRECT_KEY')); |
| 163 | 163 | $this->session_helper->generate_page($user_id, $admin, $auto_login, $viewonline, $redirect); |
| 164 | 164 | } |
| 165 | - } |
|
| 166 | - catch (http_exception $ex) // @TODO: Replace exception with own exception |
|
| 165 | + } catch (http_exception $ex) // @TODO: Replace exception with own exception |
|
| 167 | 166 | { |
| 168 | 167 | |
| 169 | 168 | $this->log->add('critical', $this->user->data['user_id'], $this->user->ip, 'LOG_TFA_EXCEPTION', false, [$ex->getMessage()]); |
@@ -177,8 +176,7 @@ discard block |
||
| 177 | 176 | { |
| 178 | 177 | $this->template->assign_var('S_ERROR', $this->user->lang($ex->getMessage())); |
| 179 | 178 | $this->session_helper->generate_page($user_id, $admin, $auto_login, $viewonline, $redirect); |
| 180 | - } |
|
| 181 | - else |
|
| 179 | + } else |
|
| 182 | 180 | { |
| 183 | 181 | throw $ex; |
| 184 | 182 | } |