@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
at recaptime-dev/main 121 lines 3.3 kB view raw
1<?php 2 3final class PhabricatorAuthListController 4 extends PhabricatorAuthProviderConfigController { 5 6 public function handleRequest(AphrontRequest $request) { 7 $viewer = $this->getViewer(); 8 9 $configs = id(new PhabricatorAuthProviderConfigQuery()) 10 ->setViewer($viewer) 11 ->execute(); 12 13 $list = new PHUIObjectItemListView(); 14 $can_manage = $this->hasApplicationCapability( 15 AuthManageProvidersCapability::CAPABILITY); 16 $is_locked = PhabricatorEnv::getEnvConfig('auth.lock-config'); 17 18 foreach ($configs as $config) { 19 $item = new PHUIObjectItemView(); 20 21 $id = $config->getID(); 22 23 $view_uri = $config->getURI(); 24 25 $provider = $config->getProvider(); 26 $name = $provider->getProviderName(); 27 28 $item 29 ->setHeader($name) 30 ->setHref($view_uri); 31 32 $domain = $provider->getProviderDomain(); 33 if ($domain !== 'self') { 34 $item->addAttribute($domain); 35 } 36 37 if ($config->getShouldAllowRegistration()) { 38 $item->addAttribute(pht('Allows Registration')); 39 } else { 40 $item->addAttribute(pht('Does Not Allow Registration')); 41 } 42 43 if ($config->getIsEnabled()) { 44 $item->setStatusIcon('fa-check-circle green'); 45 } else { 46 $item->setStatusIcon('fa-ban red'); 47 $item->addIcon('fa-ban grey', pht('Disabled')); 48 } 49 50 $list->addItem($item); 51 } 52 53 $list->setNoDataString( 54 pht( 55 '%s You have not added authentication providers yet. Use "%s" to add '. 56 'a provider, which will let users register new accounts and log in.', 57 phutil_tag( 58 'strong', 59 array(), 60 pht('No Providers Configured:')), 61 phutil_tag( 62 'a', 63 array( 64 'href' => $this->getApplicationURI('config/new/'), 65 ), 66 pht('Add Provider')))); 67 68 $crumbs = $this->buildApplicationCrumbs(); 69 $crumbs->addTextCrumb(pht('Login and Registration')); 70 $crumbs->setBorder(true); 71 72 $guidance_context = id(new PhabricatorAuthProvidersGuidanceContext()) 73 ->setCanManage($can_manage); 74 75 $guidance = id(new PhabricatorGuidanceEngine()) 76 ->setViewer($viewer) 77 ->setGuidanceContext($guidance_context) 78 ->newInfoView(); 79 80 $is_disabled = (!$can_manage || $is_locked); 81 $button = id(new PHUIButtonView()) 82 ->setTag('a') 83 ->setButtonType(PHUIButtonView::BUTTONTYPE_SIMPLE) 84 ->setIcon('fa-plus') 85 ->setDisabled($is_disabled) 86 ->setWorkflow($is_disabled) 87 ->setHref($this->getApplicationURI('config/new/')) 88 ->setText(pht('Add Provider')); 89 90 $list->setFlush(true); 91 $list = id(new PHUIObjectBoxView()) 92 ->setHeaderText(pht('Providers')) 93 ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) 94 ->appendChild($list); 95 96 $title = pht('Login and Registration Providers'); 97 $header = id(new PHUIHeaderView()) 98 ->setHeader($title) 99 ->setHeaderIcon('fa-key') 100 ->addActionLink($button); 101 102 $view = id(new PHUITwoColumnView()) 103 ->setHeader($header) 104 ->setFooter( 105 array( 106 $guidance, 107 $list, 108 )); 109 110 $nav = $this->newNavigation() 111 ->setCrumbs($crumbs) 112 ->appendChild($view); 113 114 $nav->selectFilter('login'); 115 116 return $this->newPage() 117 ->setTitle($title) 118 ->appendChild($nav); 119 } 120 121}