Differential D19935 Diff 47692 src/applications/auth/controller/mfa/PhabricatorAuthFactorProviderListController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/auth/controller/mfa/PhabricatorAuthFactorProviderListController.php
- This file was added.
<?php | |||||
final class PhabricatorAuthFactorProviderListController | |||||
extends PhabricatorAuthProviderController { | |||||
public function handleRequest(AphrontRequest $request) { | |||||
$viewer = $this->getViewer(); | |||||
$can_manage = $this->hasApplicationCapability( | |||||
AuthManageProvidersCapability::CAPABILITY); | |||||
$providers = id(new PhabricatorAuthFactorProviderQuery()) | |||||
->setViewer($viewer) | |||||
->execute(); | |||||
$list = new PHUIObjectItemListView(); | |||||
foreach ($providers as $provider) { | |||||
$item = id(new PHUIObjectItemView()) | |||||
->setObjectName($provider->getObjectName()) | |||||
->setHeader($provider->getDisplayName()) | |||||
amckinley: Shouldn't we have some kind of `getName` method on the provider objects? | |||||
Done Inline ActionsYeah, we ended up with a fair number of copies of this. I'll throw it in a method. epriestley: Yeah, we ended up with a fair number of copies of this. I'll throw it in a method. | |||||
->setHref($provider->getURI()); | |||||
$list->addItem($item); | |||||
} | |||||
$list->setNoDataString( | |||||
pht('You have not configured any multi-factor providers yet.')); | |||||
$crumbs = $this->buildApplicationCrumbs() | |||||
->addTextCrumb(pht('Multi-Factor')) | |||||
->setBorder(true); | |||||
$button = id(new PHUIButtonView()) | |||||
->setTag('a') | |||||
->setButtonType(PHUIButtonView::BUTTONTYPE_SIMPLE) | |||||
->setHref($this->getApplicationURI('mfa/edit/')) | |||||
->setIcon('fa-plus') | |||||
->setDisabled(!$can_manage) | |||||
->setWorkflow(true) | |||||
->setText(pht('Add MFA Provider')); | |||||
$list->setFlush(true); | |||||
$list = id(new PHUIObjectBoxView()) | |||||
->setHeaderText(pht('MFA Providers')) | |||||
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) | |||||
->appendChild($list); | |||||
$title = pht('MFA Providers'); | |||||
$header = id(new PHUIHeaderView()) | |||||
->setHeader($title) | |||||
->setHeaderIcon('fa-mobile') | |||||
->addActionLink($button); | |||||
$view = id(new PHUITwoColumnView()) | |||||
->setHeader($header) | |||||
->setFooter( | |||||
array( | |||||
$list, | |||||
)); | |||||
$nav = $this->newNavigation() | |||||
->setCrumbs($crumbs) | |||||
->appendChild($view); | |||||
$nav->selectFilter('mfa'); | |||||
return $this->newPage() | |||||
->setTitle($title) | |||||
->appendChild($nav); | |||||
} | |||||
} |
Shouldn't we have some kind of getName method on the provider objects?