@@ -62,7 +62,7 @@ |
||
| 62 | 62 | |
| 63 | 63 | $usedToken = null; |
| 64 | 64 | foreach ($scratchTokens as $scratchToken) { |
| 65 | - if (password_verify($data, $scratchToken)){ |
|
| 65 | + if (password_verify($data, $scratchToken)) { |
|
| 66 | 66 | $usedToken = $scratchToken; |
| 67 | 67 | SessionAlert::quick("Hey, it looks like you used a scratch token to log in. Would you like to change your multi-factor authentication configuration?", 'alert-warning'); |
| 68 | 68 | WebRequest::setPostLoginRedirect($this->getConfiguration()->getBaseUrl() . "/internal.php/multiFactor"); |
@@ -93,7 +93,8 @@ discard block |
||
| 93 | 93 | return $this->configuration; |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | - public function deleteCredential(User $user) { |
|
| 96 | + public function deleteCredential(User $user) |
|
| 97 | + { |
|
| 97 | 98 | // get this factor |
| 98 | 99 | $statement = $this->database->prepare('SELECT * FROM credential WHERE user = :user AND type = :type'); |
| 99 | 100 | $statement->execute(array(':user' => $user->getId(), ':type' => $this->type)); |
@@ -114,8 +115,7 @@ discard block |
||
| 114 | 115 | $sql = 'UPDATE credential SET factor = factor - 1 WHERE user = :user AND factor > :factor'; |
| 115 | 116 | $statement = $this->database->prepare($sql); |
| 116 | 117 | $statement->execute(array(':user' => $user->getId(), ':factor' => $stage)); |
| 117 | - } |
|
| 118 | - else { |
|
| 118 | + } else { |
|
| 119 | 119 | // There are other auth factors at this point. Don't renumber the factors just yet. |
| 120 | 120 | } |
| 121 | 121 | |
@@ -143,7 +143,8 @@ discard block |
||
| 143 | 143 | * |
| 144 | 144 | * @return bool |
| 145 | 145 | */ |
| 146 | - public function userIsEnrolled($userId) { |
|
| 146 | + public function userIsEnrolled($userId) |
|
| 147 | + { |
|
| 147 | 148 | $cred = $this->getCredentialData($userId); |
| 148 | 149 | |
| 149 | 150 | return $cred !== null; |
@@ -30,8 +30,7 @@ |
||
| 30 | 30 | public function authenticate(User $user, $data) |
| 31 | 31 | { |
| 32 | 32 | $storedData = $this->getCredentialData($user->getId()); |
| 33 | - if($storedData === null) |
|
| 34 | - { |
|
| 33 | + if($storedData === null) { |
|
| 35 | 34 | // No available credential matching these parameters |
| 36 | 35 | return false; |
| 37 | 36 | } |
@@ -77,14 +77,12 @@ discard block |
||
| 77 | 77 | { |
| 78 | 78 | if ($this->checkIdentificationCache($onWikiName)) { |
| 79 | 79 | return true; |
| 80 | - } |
|
| 81 | - else { |
|
| 80 | + } else { |
|
| 82 | 81 | if ($this->isIdentifiedOnWiki($onWikiName)) { |
| 83 | 82 | $this->cacheIdentificationStatus($onWikiName); |
| 84 | 83 | |
| 85 | 84 | return true; |
| 86 | - } |
|
| 87 | - else { |
|
| 85 | + } else { |
|
| 88 | 86 | return false; |
| 89 | 87 | } |
| 90 | 88 | } |
@@ -190,7 +188,8 @@ discard block |
||
| 190 | 188 | $endpoint = $this->siteConfiguration->getMetaWikimediaWebServiceEndpoint(); |
| 191 | 189 | $response = $this->httpHelper->get($endpoint, $parameters); |
| 192 | 190 | $response = json_decode($response, true); |
| 193 | - } catch (CurlException $ex) { |
|
| 191 | + } |
|
| 192 | + catch (CurlException $ex) { |
|
| 194 | 193 | // failed getting identification status, so throw a nicer error. |
| 195 | 194 | $message = 'Could not contact metawiki API to determine user\' identification status. ' |
| 196 | 195 | . 'This is probably a transient error, so please try again.'; |
@@ -90,12 +90,10 @@ |
||
| 90 | 90 | |
| 91 | 91 | if ($statement->execute()) { |
| 92 | 92 | $this->id = (int)$this->dbObject->lastInsertId(); |
| 93 | - } |
|
| 94 | - else { |
|
| 93 | + } else { |
|
| 95 | 94 | throw new Exception($statement->errorInfo()); |
| 96 | 95 | } |
| 97 | - } |
|
| 98 | - else { |
|
| 96 | + } else { |
|
| 99 | 97 | $statement = $this->dbObject->prepare(<<<SQL |
| 100 | 98 | UPDATE oauthidentity SET |
| 101 | 99 | iss = :iss |
@@ -130,8 +130,7 @@ discard block |
||
| 130 | 130 | { |
| 131 | 131 | if ($timeout === null) { |
| 132 | 132 | $this->timeout = null; |
| 133 | - } |
|
| 134 | - else { |
|
| 133 | + } else { |
|
| 135 | 134 | $this->timeout = $timeout->format('Y-m-d H:i:s'); |
| 136 | 135 | } |
| 137 | 136 | } |
@@ -188,12 +187,10 @@ discard block |
||
| 188 | 187 | |
| 189 | 188 | if ($statement->execute()) { |
| 190 | 189 | $this->id = (int)$this->dbObject->lastInsertId(); |
| 191 | - } |
|
| 192 | - else { |
|
| 190 | + } else { |
|
| 193 | 191 | throw new Exception($statement->errorInfo()); |
| 194 | 192 | } |
| 195 | - } |
|
| 196 | - else { |
|
| 193 | + } else { |
|
| 197 | 194 | // update |
| 198 | 195 | $statement = $this->dbObject->prepare(<<<SQL |
| 199 | 196 | UPDATE credential |
@@ -58,7 +58,8 @@ discard block |
||
| 58 | 58 | /** |
| 59 | 59 | * This feels like the least bad place to put this method. |
| 60 | 60 | */ |
| 61 | - public static function getTaskDescriptions() { |
|
| 61 | + public static function getTaskDescriptions() |
|
| 62 | + { |
|
| 62 | 63 | return array( |
| 63 | 64 | BotCreationTask::class => 'Create account (via bot)', |
| 64 | 65 | UserCreationTask::class => 'Create account (via OAuth)', |
@@ -90,12 +91,10 @@ discard block |
||
| 90 | 91 | |
| 91 | 92 | if ($statement->execute()) { |
| 92 | 93 | $this->id = (int)$this->dbObject->lastInsertId(); |
| 93 | - } |
|
| 94 | - else { |
|
| 94 | + } else { |
|
| 95 | 95 | throw new Exception($statement->errorInfo()); |
| 96 | 96 | } |
| 97 | - } |
|
| 98 | - else { |
|
| 97 | + } else { |
|
| 99 | 98 | // update |
| 100 | 99 | $statement = $this->dbObject->prepare(<<<SQL |
| 101 | 100 | UPDATE jobqueue SET |
@@ -42,12 +42,10 @@ |
||
| 42 | 42 | |
| 43 | 43 | if ($statement->execute()) { |
| 44 | 44 | $this->id = (int)$this->dbObject->lastInsertId(); |
| 45 | - } |
|
| 46 | - else { |
|
| 45 | + } else { |
|
| 47 | 46 | throw new Exception($statement->errorInfo()); |
| 48 | 47 | } |
| 49 | - } |
|
| 50 | - else { |
|
| 48 | + } else { |
|
| 51 | 49 | // update |
| 52 | 50 | $statement = $this->dbObject->prepare(<<<SQL |
| 53 | 51 | UPDATE oauthtoken |
@@ -64,12 +64,10 @@ discard block |
||
| 64 | 64 | |
| 65 | 65 | if ($user === false) { |
| 66 | 66 | self::$currentUser = new CommunityUser(); |
| 67 | - } |
|
| 68 | - else { |
|
| 67 | + } else { |
|
| 69 | 68 | self::$currentUser = $user; |
| 70 | 69 | } |
| 71 | - } |
|
| 72 | - else { |
|
| 70 | + } else { |
|
| 73 | 71 | $anonymousCoward = new CommunityUser(); |
| 74 | 72 | |
| 75 | 73 | self::$currentUser = $anonymousCoward; |
@@ -203,12 +201,10 @@ discard block |
||
| 203 | 201 | |
| 204 | 202 | if ($statement->execute()) { |
| 205 | 203 | $this->id = (int)$this->dbObject->lastInsertId(); |
| 206 | - } |
|
| 207 | - else { |
|
| 204 | + } else { |
|
| 208 | 205 | throw new Exception($statement->errorInfo()); |
| 209 | 206 | } |
| 210 | - } |
|
| 211 | - else { |
|
| 207 | + } else { |
|
| 212 | 208 | // update |
| 213 | 209 | $statement = $this->dbObject->prepare(<<<SQL |
| 214 | 210 | UPDATE `user` SET |
@@ -533,12 +529,10 @@ discard block |
||
| 533 | 529 | if ($this->forceidentified === 0 || $this->forceidentified === "0") { |
| 534 | 530 | // User forced to unidentified in the database. |
| 535 | 531 | return false; |
| 536 | - } |
|
| 537 | - elseif ($this->forceidentified === 1 || $this->forceidentified === "1") { |
|
| 532 | + } elseif ($this->forceidentified === 1 || $this->forceidentified === "1") { |
|
| 538 | 533 | // User forced to identified in the database. |
| 539 | 534 | return true; |
| 540 | - } |
|
| 541 | - else { |
|
| 535 | + } else { |
|
| 542 | 536 | // User not forced to any particular identified status; consult IdentificationVerifier |
| 543 | 537 | return $iv->isUserIdentified($this->getOnWikiName()); |
| 544 | 538 | } |
@@ -549,7 +543,8 @@ discard block |
||
| 549 | 543 | * |
| 550 | 544 | * @return bool|null |
| 551 | 545 | */ |
| 552 | - public function getForceIdentified() { |
|
| 546 | + public function getForceIdentified() |
|
| 547 | + { |
|
| 553 | 548 | return $this->forceidentified; |
| 554 | 549 | } |
| 555 | 550 | |