@@ -62,8 +62,7 @@ |
||
| 62 | 62 | |
| 63 | 63 | $this->assignCSRFToken(); |
| 64 | 64 | $this->setTemplate('search/searchResult.tpl'); |
| 65 | - } |
|
| 66 | - else { |
|
| 65 | + } else { |
|
| 67 | 66 | $this->assignCSRFToken(); |
| 68 | 67 | $this->setTemplate('search/searchForm.tpl'); |
| 69 | 68 | } |
@@ -65,8 +65,7 @@ discard block |
||
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | $user = User::getByUsername($username, $database); |
| 68 | - } |
|
| 69 | - else { |
|
| 68 | + } else { |
|
| 70 | 69 | $user = User::getById($partialId, $database); |
| 71 | 70 | } |
| 72 | 71 | |
@@ -105,8 +104,7 @@ discard block |
||
| 105 | 104 | |
| 106 | 105 | return; |
| 107 | 106 | } |
| 108 | - } |
|
| 109 | - else { |
|
| 107 | + } else { |
|
| 110 | 108 | $this->assign('showSignIn', true); |
| 111 | 109 | |
| 112 | 110 | $this->setupPartial(); |
@@ -131,8 +129,7 @@ discard block |
||
| 131 | 129 | if (WebRequest::isHttps()) { |
| 132 | 130 | // Client can clearly use HTTPS, so let's enforce it for all connections. |
| 133 | 131 | $this->headerQueue[] = "Strict-Transport-Security: max-age=15768000"; |
| 134 | - } |
|
| 135 | - else { |
|
| 132 | + } else { |
|
| 136 | 133 | // This is the login form, not the request form. We need protection here. |
| 137 | 134 | $this->redirectUrl('https://' . WebRequest::serverName() . WebRequest::requestUri()); |
| 138 | 135 | |
@@ -166,8 +163,7 @@ discard block |
||
| 166 | 163 | $username = $this->partialUser->getUsername(); |
| 167 | 164 | |
| 168 | 165 | $this->setupAlternates($this->partialUser, $partialStage, $database); |
| 169 | - } |
|
| 170 | - else { |
|
| 166 | + } else { |
|
| 171 | 167 | // No, see if we've preloaded a username |
| 172 | 168 | $preloadUsername = WebRequest::getString('tplUsername'); |
| 173 | 169 | if ($preloadUsername !== null) { |
@@ -194,13 +190,11 @@ discard block |
||
| 194 | 190 | $redirectDestination = WebRequest::clearPostLoginRedirect(); |
| 195 | 191 | if ($redirectDestination !== null) { |
| 196 | 192 | $this->redirectUrl($redirectDestination); |
| 197 | - } |
|
| 198 | - else { |
|
| 193 | + } else { |
|
| 199 | 194 | if ($user->isNewUser()) { |
| 200 | 195 | // home page isn't allowed, go to preferences instead |
| 201 | 196 | $this->redirect('preferences'); |
| 202 | - } |
|
| 203 | - else { |
|
| 197 | + } else { |
|
| 204 | 198 | // go to the home page |
| 205 | 199 | $this->redirect(''); |
| 206 | 200 | } |
@@ -323,7 +317,8 @@ discard block |
||
| 323 | 317 | if (isset($types[$type])) { |
| 324 | 318 | $options = $types[$type]; |
| 325 | 319 | |
| 326 | - array_walk($options, function(&$val) { |
|
| 320 | + array_walk($options, function(&$val) |
|
| 321 | + { |
|
| 327 | 322 | $val = $this->names[$val]; |
| 328 | 323 | }); |
| 329 | 324 | |
@@ -116,8 +116,7 @@ |
||
| 116 | 116 | $redirectDestination = WebRequest::clearPostLoginRedirect(); |
| 117 | 117 | if ($redirectDestination !== null && !$user->isNewUser()) { |
| 118 | 118 | $this->redirectUrl($redirectDestination); |
| 119 | - } |
|
| 120 | - else { |
|
| 119 | + } else { |
|
| 121 | 120 | $this->redirect('preferences', null, null, 'internal.php'); |
| 122 | 121 | } |
| 123 | 122 | } |
@@ -52,8 +52,7 @@ |
||
| 52 | 52 | SessionAlert::success('Password changed successfully!'); |
| 53 | 53 | |
| 54 | 54 | $this->redirect('preferences'); |
| 55 | - } |
|
| 56 | - else { |
|
| 55 | + } else { |
|
| 57 | 56 | $this->assignCSRFToken(); |
| 58 | 57 | $this->setTemplate('preferences/changePassword.tpl'); |
| 59 | 58 | $this->addJs("/vendor/dropbox/zxcvbn/dist/zxcvbn.js"); |
@@ -46,8 +46,7 @@ discard block |
||
| 46 | 46 | SessionAlert::success('<strong>Your password reset request has been completed.</strong> If the details you have provided match our records, you should receive an email shortly.'); |
| 47 | 47 | |
| 48 | 48 | $this->redirect('login'); |
| 49 | - } |
|
| 50 | - else { |
|
| 49 | + } else { |
|
| 51 | 50 | $this->assignCSRFToken(); |
| 52 | 51 | $this->setTemplate('forgot-password/forgotpw.tpl'); |
| 53 | 52 | } |
@@ -130,8 +129,7 @@ discard block |
||
| 130 | 129 | |
| 131 | 130 | return; |
| 132 | 131 | } |
| 133 | - } |
|
| 134 | - else { |
|
| 132 | + } else { |
|
| 135 | 133 | $this->assignCSRFToken(); |
| 136 | 134 | $this->assign('user', $user); |
| 137 | 135 | $this->setTemplate('forgot-password/forgotpwreset.tpl'); |
@@ -46,8 +46,7 @@ |
||
| 46 | 46 | SessionAlert::success("Preferences updated!"); |
| 47 | 47 | |
| 48 | 48 | $this->redirect(''); |
| 49 | - } |
|
| 50 | - else { |
|
| 49 | + } else { |
|
| 51 | 50 | $this->assignCSRFToken(); |
| 52 | 51 | $this->setTemplate('preferences/prefs.tpl'); |
| 53 | 52 | $this->assign("enforceOAuth", $enforceOAuth); |
@@ -94,13 +94,11 @@ discard block |
||
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | $this->redirect('multiFactor'); |
| 97 | - } |
|
| 98 | - else { |
|
| 97 | + } else { |
|
| 99 | 98 | SessionAlert::error('Error enabling YubiKey OTP - invalid credentials.'); |
| 100 | 99 | $this->redirect('multiFactor'); |
| 101 | 100 | } |
| 102 | - } |
|
| 103 | - else { |
|
| 101 | + } else { |
|
| 104 | 102 | if ($otpCredentialProvider->userIsEnrolled($currentUser->getId())) { |
| 105 | 103 | // user is not enrolled, we shouldn't have got here. |
| 106 | 104 | throw new ApplicationLogicException('User is already enrolled in the selected MFA mechanism'); |
@@ -162,8 +160,7 @@ discard block |
||
| 162 | 160 | $this->setTemplate('mfa/enableTotpEnroll.tpl'); |
| 163 | 161 | |
| 164 | 162 | return; |
| 165 | - } |
|
| 166 | - else { |
|
| 163 | + } else { |
|
| 167 | 164 | SessionAlert::error('Error enabling TOTP - invalid credentials.'); |
| 168 | 165 | $this->redirect('multiFactor'); |
| 169 | 166 | |
@@ -188,8 +185,7 @@ discard block |
||
| 188 | 185 | $this->setTemplate('mfa/regenScratchTokens.tpl'); |
| 189 | 186 | return; |
| 190 | 187 | } |
| 191 | - } |
|
| 192 | - else { |
|
| 188 | + } else { |
|
| 193 | 189 | $otpCredentialProvider->deleteCredential($currentUser); |
| 194 | 190 | SessionAlert::error('Error enabling TOTP: invalid token provided'); |
| 195 | 191 | } |
@@ -197,8 +193,7 @@ discard block |
||
| 197 | 193 | |
| 198 | 194 | $this->redirect('multiFactor'); |
| 199 | 195 | return; |
| 200 | - } |
|
| 201 | - else { |
|
| 196 | + } else { |
|
| 202 | 197 | SessionAlert::error('Error enabling TOTP - no enrollment found or enrollment expired.'); |
| 203 | 198 | $this->redirect('multiFactor'); |
| 204 | 199 | |
@@ -208,8 +203,7 @@ discard block |
||
| 208 | 203 | |
| 209 | 204 | // urgh, dunno what happened, but it's not something expected. |
| 210 | 205 | throw new ApplicationLogicException(); |
| 211 | - } |
|
| 212 | - else { |
|
| 206 | + } else { |
|
| 213 | 207 | if ($otpCredentialProvider->userIsEnrolled($currentUser->getId())) { |
| 214 | 208 | // user is not enrolled, we shouldn't have got here. |
| 215 | 209 | throw new ApplicationLogicException('User is already enrolled in the selected MFA mechanism'); |
@@ -236,7 +230,8 @@ discard block |
||
| 236 | 230 | $this->deleteCredential($database, $currentUser, $otpCredentialProvider, $factorType); |
| 237 | 231 | } |
| 238 | 232 | |
| 239 | - protected function enableU2F() { |
|
| 233 | + protected function enableU2F() |
|
| 234 | + { |
|
| 240 | 235 | $database = $this->getDatabase(); |
| 241 | 236 | $currentUser = User::getCurrent($database); |
| 242 | 237 | |
@@ -289,8 +284,7 @@ discard block |
||
| 289 | 284 | $this->setTemplate('mfa/enableU2FEnroll.tpl'); |
| 290 | 285 | |
| 291 | 286 | return; |
| 292 | - } |
|
| 293 | - else { |
|
| 287 | + } else { |
|
| 294 | 288 | SessionAlert::error('Error enabling TOTP - invalid credentials.'); |
| 295 | 289 | $this->redirect('multiFactor'); |
| 296 | 290 | |
@@ -320,8 +314,7 @@ discard block |
||
| 320 | 314 | |
| 321 | 315 | $this->redirect('multiFactor'); |
| 322 | 316 | return; |
| 323 | - } |
|
| 324 | - else { |
|
| 317 | + } else { |
|
| 325 | 318 | SessionAlert::error('Error enabling TOTP - no enrollment found or enrollment expired.'); |
| 326 | 319 | $this->redirect('multiFactor'); |
| 327 | 320 | |
@@ -331,8 +324,7 @@ discard block |
||
| 331 | 324 | |
| 332 | 325 | // urgh, dunno what happened, but it's not something expected. |
| 333 | 326 | throw new ApplicationLogicException(); |
| 334 | - } |
|
| 335 | - else { |
|
| 327 | + } else { |
|
| 336 | 328 | if ($otpCredentialProvider->userIsEnrolled($currentUser->getId())) { |
| 337 | 329 | // user is not enrolled, we shouldn't have got here. |
| 338 | 330 | throw new ApplicationLogicException('User is already enrolled in the selected MFA mechanism'); |
@@ -347,7 +339,8 @@ discard block |
||
| 347 | 339 | } |
| 348 | 340 | } |
| 349 | 341 | |
| 350 | - protected function disableU2F() { |
|
| 342 | + protected function disableU2F() |
|
| 343 | + { |
|
| 351 | 344 | $database = $this->getDatabase(); |
| 352 | 345 | $currentUser = User::getCurrent($database); |
| 353 | 346 | |
@@ -381,13 +374,11 @@ discard block |
||
| 381 | 374 | $tokens = $otpCredentialProvider->getTokens(); |
| 382 | 375 | $this->assign('tokens', $tokens); |
| 383 | 376 | $this->setTemplate('mfa/regenScratchTokens.tpl'); |
| 384 | - } |
|
| 385 | - else { |
|
| 377 | + } else { |
|
| 386 | 378 | SessionAlert::error('Error refreshing scratch tokens - invalid credentials.'); |
| 387 | 379 | $this->redirect('multiFactor'); |
| 388 | 380 | } |
| 389 | - } |
|
| 390 | - else { |
|
| 381 | + } else { |
|
| 391 | 382 | $this->assignCSRFToken(); |
| 392 | 383 | |
| 393 | 384 | $this->assign('alertmessage', 'To regenerate your emergency scratch tokens, please prove you are who you say you are by providing the information below. Note that continuing will invalidate all remaining scratch tokens, and provide a set of new ones.'); |
@@ -425,13 +416,11 @@ discard block |
||
| 425 | 416 | $otpCredentialProvider->deleteCredential($currentUser); |
| 426 | 417 | SessionAlert::success('Disabled ' . $factorType . '.'); |
| 427 | 418 | $this->redirect('multiFactor'); |
| 428 | - } |
|
| 429 | - else { |
|
| 419 | + } else { |
|
| 430 | 420 | SessionAlert::error('Error disabling ' . $factorType . ' - invalid credentials.'); |
| 431 | 421 | $this->redirect('multiFactor'); |
| 432 | 422 | } |
| 433 | - } |
|
| 434 | - else { |
|
| 423 | + } else { |
|
| 435 | 424 | if (!$otpCredentialProvider->userIsEnrolled($currentUser->getId())) { |
| 436 | 425 | // user is not enrolled, we shouldn't have got here. |
| 437 | 426 | throw new ApplicationLogicException('User is not enrolled in the selected MFA mechanism'); |
@@ -53,8 +53,7 @@ discard block |
||
| 53 | 53 | $this->setTemplate($this->getRegistrationTemplate()); |
| 54 | 54 | $this->addJs("/vendor/dropbox/zxcvbn/dist/zxcvbn.js"); |
| 55 | 55 | } |
| 56 | - } |
|
| 57 | - else { |
|
| 56 | + } else { |
|
| 58 | 57 | $this->assignCSRFToken(); |
| 59 | 58 | $this->assign("useOAuthSignup", $useOAuthSignup); |
| 60 | 59 | $this->setTemplate($this->getRegistrationTemplate()); |
@@ -214,8 +213,7 @@ discard block |
||
| 214 | 213 | $authoriseUrl = $oauth->getRequestToken(); |
| 215 | 214 | WebRequest::setOAuthPartialLogin($user); |
| 216 | 215 | $this->redirectUrl($authoriseUrl); |
| 217 | - } |
|
| 218 | - else { |
|
| 216 | + } else { |
|
| 219 | 217 | // only notify if we're not using the oauth signup. |
| 220 | 218 | $this->getNotificationHelper()->userNew($user); |
| 221 | 219 | WebRequest::setLoggedInUser($user); |
@@ -116,7 +116,8 @@ discard block |
||
| 116 | 116 | $job->setDatabase($database); |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | - $this->getTypeAheadHelper()->defineTypeAheadSource('username-typeahead', function() use ($database) { |
|
| 119 | + $this->getTypeAheadHelper()->defineTypeAheadSource('username-typeahead', function() use ($database) |
|
| 120 | + { |
|
| 120 | 121 | return UserSearchHelper::get($database)->fetchColumn('username'); |
| 121 | 122 | }); |
| 122 | 123 | |
@@ -158,8 +159,7 @@ discard block |
||
| 158 | 159 | ->byObjectId($job->getId())->getRecordCount($logCount)->fetch(); |
| 159 | 160 | if ($logCount === 0) { |
| 160 | 161 | $this->assign('log', array()); |
| 161 | - } |
|
| 162 | - else { |
|
| 162 | + } else { |
|
| 163 | 163 | list($users, $logData) = LogHelper::prepareLogsForTemplate($logs, $database, $this->getSiteConfiguration()); |
| 164 | 164 | |
| 165 | 165 | $this->assign("log", $logData); |