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 @@ -714,7 +714,14 @@ if (isset($validation_results[$factor_phid])) { continue; } - $validation_results[$factor_phid] = new PhabricatorAuthFactorResult(); + + $issued_challenges = idx($challenge_map, $factor_phid, array()); + + $validation_results[$factor_phid] = $impl->getResultForPrompt( + $factor, + $viewer, + $request, + $issued_challenges); } throw id(new PhabricatorAuthHighSecurityRequiredException()) 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 @@ -221,6 +221,40 @@ return $result; } + final public function getResultForPrompt( + PhabricatorAuthFactorConfig $config, + PhabricatorUser $viewer, + AphrontRequest $request, + array $challenges) { + assert_instances_of($challenges, 'PhabricatorAuthChallenge'); + + $result = $this->newResultForPrompt( + $config, + $viewer, + $request, + $challenges); + + if (!$this->isAuthResult($result)) { + throw new Exception( + pht( + 'Expected "newResultForPrompt()" to return an object of class "%s", '. + 'but it returned something else ("%s"; in "%s").', + 'PhabricatorAuthFactorResult', + phutil_describe_type($result), + get_class($this))); + } + + return $result; + } + + protected function newResultForPrompt( + PhabricatorAuthFactorConfig $config, + PhabricatorUser $viewer, + AphrontRequest $request, + array $challenges) { + return $this->newResult(); + } + abstract protected function newResultFromIssuedChallenges( PhabricatorAuthFactorConfig $config, PhabricatorUser $viewer, diff --git a/src/applications/auth/factor/PhabricatorDuoAuthFactor.php b/src/applications/auth/factor/PhabricatorDuoAuthFactor.php --- a/src/applications/auth/factor/PhabricatorDuoAuthFactor.php +++ b/src/applications/auth/factor/PhabricatorDuoAuthFactor.php @@ -681,6 +681,19 @@ AphrontRequest $request, array $challenges) { + return $this->getResultForPrompt( + $config, + $viewer, + $request, + $challenges); + } + + protected function newResultForPrompt( + PhabricatorAuthFactorConfig $config, + PhabricatorUser $viewer, + AphrontRequest $request, + array $challenges) { + $result = $this->newResult() ->setIsContinue(true) ->setErrorMessage(