diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -2241,7 +2241,6 @@ 'PhabricatorAuthFactorProviderTransactionType' => 'applications/auth/xaction/PhabricatorAuthFactorProviderTransactionType.php', 'PhabricatorAuthFactorProviderViewController' => 'applications/auth/controller/mfa/PhabricatorAuthFactorProviderViewController.php', 'PhabricatorAuthFactorResult' => 'applications/auth/factor/PhabricatorAuthFactorResult.php', - 'PhabricatorAuthFactorResultException' => 'applications/auth/exception/PhabricatorAuthFactorResultException.php', 'PhabricatorAuthFactorTestCase' => 'applications/auth/factor/__tests__/PhabricatorAuthFactorTestCase.php', 'PhabricatorAuthFinishController' => 'applications/auth/controller/PhabricatorAuthFinishController.php', 'PhabricatorAuthHMACKey' => 'applications/auth/storage/PhabricatorAuthHMACKey.php', @@ -7970,7 +7969,6 @@ 'PhabricatorAuthFactorProviderTransactionType' => 'PhabricatorModularTransactionType', 'PhabricatorAuthFactorProviderViewController' => 'PhabricatorAuthFactorProviderController', 'PhabricatorAuthFactorResult' => 'Phobject', - 'PhabricatorAuthFactorResultException' => 'Exception', 'PhabricatorAuthFactorTestCase' => 'PhabricatorTestCase', 'PhabricatorAuthFinishController' => 'PhabricatorAuthController', 'PhabricatorAuthHMACKey' => 'PhabricatorAuthDAO', diff --git a/src/applications/auth/engine/PhabricatorAuthSessionEngine.php b/src/applications/auth/engine/PhabricatorAuthSessionEngine.php --- a/src/applications/auth/engine/PhabricatorAuthSessionEngine.php +++ b/src/applications/auth/engine/PhabricatorAuthSessionEngine.php @@ -540,14 +540,22 @@ $provider = $factor->getFactorProvider(); $impl = $provider->getFactor(); - try { - $new_challenges = $impl->getNewIssuedChallenges( - $factor, - $viewer, - $issued_challenges); - } catch (PhabricatorAuthFactorResultException $ex) { - $ok = false; - $validation_results[$factor_phid] = $ex->getResult(); + $new_challenges = $impl->getNewIssuedChallenges( + $factor, + $viewer, + $issued_challenges); + + // NOTE: We may get a list of challenges back, or may just get an early + // result. For example, this can happen on an SMS factor if all SMS + // mailers have been disabled. + if ($new_challenges instanceof PhabricatorAuthFactorResult) { + $result = $new_challenges; + + if (!$result->getIsValid()) { + $ok = false; + } + + $validation_results[$factor_phid] = $result; $challenge_map[$factor_phid] = $issued_challenges; continue; } diff --git a/src/applications/auth/exception/PhabricatorAuthFactorResultException.php b/src/applications/auth/exception/PhabricatorAuthFactorResultException.php deleted file mode 100644 --- a/src/applications/auth/exception/PhabricatorAuthFactorResultException.php +++ /dev/null @@ -1,17 +0,0 @@ -result = $result; - parent::__construct(); - } - - public function getResult() { - return $this->result; - } - -} diff --git a/src/applications/auth/factor/PhabricatorAuthFactor.php b/src/applications/auth/factor/PhabricatorAuthFactor.php --- a/src/applications/auth/factor/PhabricatorAuthFactor.php +++ b/src/applications/auth/factor/PhabricatorAuthFactor.php @@ -141,6 +141,11 @@ $viewer, $challenges); + if ($new_challenges instanceof PhabricatorAuthFactorResult) { + unset($unguarded); + return $new_challenges; + } + assert_instances_of($new_challenges, 'PhabricatorAuthChallenge'); foreach ($new_challenges as $new_challenge) { @@ -493,10 +498,6 @@ $rows); } - final protected function throwResult(PhabricatorAuthFactorResult $result) { - throw new PhabricatorAuthFactorResultException($result); - } - final protected function getInstallDisplayName() { $uri = PhabricatorEnv::getURI('/'); $uri = new PhutilURI($uri); diff --git a/src/applications/auth/factor/PhabricatorSMSAuthFactor.php b/src/applications/auth/factor/PhabricatorSMSAuthFactor.php --- a/src/applications/auth/factor/PhabricatorSMSAuthFactor.php +++ b/src/applications/auth/factor/PhabricatorSMSAuthFactor.php @@ -195,35 +195,29 @@ } if (!$this->loadUserContactNumber($viewer)) { - $result = $this->newResult() + return $this->newResult() ->setIsError(true) ->setErrorMessage( pht( 'Your account has no primary contact number.')); - - $this->throwResult($result); } if (!$this->isSMSMailerConfigured()) { - $result = $this->newResult() + return $this->newResult() ->setIsError(true) ->setErrorMessage( pht( 'No outbound mailer which can deliver SMS messages is '. 'configured.')); - - $this->throwResult($result); } if (!$this->hasCSRF($config)) { - $result = $this->newResult() + return $this->newResult() ->setIsContinue(true) ->setErrorMessage( pht( 'A text message with an authorization code will be sent to your '. 'primary contact number.')); - - $this->throwResult($result); } // Otherwise, issue a new challenge.