public function execute(PhutilArgumentParser $args) { $factors = PhabricatorAuthFactor::getAllFactors(); $console = PhutilConsole::getConsole(); foreach ($factors as $factor) { $console->writeOut("%s\t%s\n", $factor->getFactorKey(), $factor->getFactorName()); } return 0; }
private function processNew(AphrontRequest $request) { $viewer = $request->getUser(); $user = $this->getUser(); $token = id(new PhabricatorAuthSessionEngine())->requireHighSecuritySession($viewer, $request, $this->getPanelURI()); $factors = PhabricatorAuthFactor::getAllFactors(); $form = id(new AphrontFormView())->setUser($viewer); $type = $request->getStr('type'); if (empty($factors[$type]) || !$request->isFormPost()) { $factor = null; } else { $factor = $factors[$type]; } $dialog = id(new AphrontDialogView())->setUser($viewer)->addHiddenInput('new', true); if ($factor === null) { $choice_control = id(new AphrontFormRadioButtonControl())->setName('type')->setValue(key($factors)); foreach ($factors as $available_factor) { $choice_control->addButton($available_factor->getFactorKey(), $available_factor->getFactorName(), $available_factor->getFactorDescription()); } $dialog->appendParagraph(pht('Adding an additional authentication factor improves the security ' . 'of your account. Choose the type of factor to add:')); $form->appendChild($choice_control); } else { $dialog->addHiddenInput('type', $type); $config = $factor->processAddFactorForm($form, $request, $user); if ($config) { $config->save(); $log = PhabricatorUserLog::initializeNewLog($viewer, $user->getPHID(), PhabricatorUserLog::ACTION_MULTI_ADD); $log->save(); $user->updateMultiFactorEnrollment(); // Terminate other sessions so they must log in and survive the // multi-factor auth check. id(new PhabricatorAuthSessionEngine())->terminateLoginSessions($user, $request->getCookie(PhabricatorCookies::COOKIE_SESSION)); return id(new AphrontRedirectResponse())->setURI($this->getPanelURI('?id=' . $config->getID())); } } $dialog->setWidth(AphrontDialogView::WIDTH_FORM)->setTitle(pht('Add Authentication Factor'))->appendChild($form->buildLayoutView())->addSubmitButton(pht('Continue'))->addCancelButton($this->getPanelURI()); return id(new AphrontDialogResponse())->setDialog($dialog); }
public function testGetAllFactors() { PhabricatorAuthFactor::getAllFactors(); $this->assertTrue(true); }
public function getImplementation() { return idx(PhabricatorAuthFactor::getAllFactors(), $this->getFactorKey()); }