@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
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Allow login to be disabled for authentication providers

Summary:
Fixes T9997. This was in the database since v0, I just never hooked up the UI since it wasn't previously meaningful.

However, it now makes sense to have a provider like Asana with login disabled and use it only for integrations.

Test Plan: Disabled login on a provider, verified it was no longer available for login/registration but still linkable.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T9997

Differential Revision: https://secure.phabricator.com/D14794

+44
+21
src/applications/auth/controller/config/PhabricatorAuthEditController.php
··· 79 79 80 80 $errors = array(); 81 81 82 + $v_login = $config->getShouldAllowLogin(); 82 83 $v_registration = $config->getShouldAllowRegistration(); 83 84 $v_link = $config->getShouldAllowLink(); 84 85 $v_unlink = $config->getShouldAllowUnlink(); ··· 103 104 $config->setProviderDomain($provider->getProviderDomain()); 104 105 } 105 106 } 107 + 108 + $xactions[] = id(new PhabricatorAuthProviderConfigTransaction()) 109 + ->setTransactionType( 110 + PhabricatorAuthProviderConfigTransaction::TYPE_LOGIN) 111 + ->setNewValue($request->getInt('allowLogin', 0)); 106 112 107 113 $xactions[] = id(new PhabricatorAuthProviderConfigTransaction()) 108 114 ->setTransactionType( ··· 199 205 $config_name); 200 206 } 201 207 208 + $str_login = array( 209 + phutil_tag('strong', array(), pht('Allow Login:')), 210 + ' ', 211 + pht( 212 + 'Allow users to log in using this provider. If you disable login, '. 213 + 'users can still use account integrations for this provider.'), 214 + ); 215 + 202 216 $str_registration = array( 203 217 phutil_tag('strong', array(), pht('Allow Registration:')), 204 218 ' ', ··· 268 282 ->appendChild( 269 283 id(new AphrontFormCheckboxControl()) 270 284 ->setLabel(pht('Allow')) 285 + ->addCheckbox( 286 + 'allowLogin', 287 + 1, 288 + $str_login, 289 + $v_login)) 290 + ->appendChild( 291 + id(new AphrontFormCheckboxControl()) 271 292 ->addCheckbox( 272 293 'allowRegistration', 273 294 1,
+7
src/applications/auth/editor/PhabricatorAuthProviderConfigEditor.php
··· 15 15 $types = parent::getTransactionTypes(); 16 16 17 17 $types[] = PhabricatorAuthProviderConfigTransaction::TYPE_ENABLE; 18 + $types[] = PhabricatorAuthProviderConfigTransaction::TYPE_LOGIN; 18 19 $types[] = PhabricatorAuthProviderConfigTransaction::TYPE_REGISTRATION; 19 20 $types[] = PhabricatorAuthProviderConfigTransaction::TYPE_LINK; 20 21 $types[] = PhabricatorAuthProviderConfigTransaction::TYPE_UNLINK; ··· 36 37 } else { 37 38 return (int)$object->getIsEnabled(); 38 39 } 40 + case PhabricatorAuthProviderConfigTransaction::TYPE_LOGIN: 41 + return (int)$object->getShouldAllowLogin(); 39 42 case PhabricatorAuthProviderConfigTransaction::TYPE_REGISTRATION: 40 43 return (int)$object->getShouldAllowRegistration(); 41 44 case PhabricatorAuthProviderConfigTransaction::TYPE_LINK: ··· 59 62 60 63 switch ($xaction->getTransactionType()) { 61 64 case PhabricatorAuthProviderConfigTransaction::TYPE_ENABLE: 65 + case PhabricatorAuthProviderConfigTransaction::TYPE_LOGIN: 62 66 case PhabricatorAuthProviderConfigTransaction::TYPE_REGISTRATION: 63 67 case PhabricatorAuthProviderConfigTransaction::TYPE_LINK: 64 68 case PhabricatorAuthProviderConfigTransaction::TYPE_UNLINK: ··· 76 80 switch ($xaction->getTransactionType()) { 77 81 case PhabricatorAuthProviderConfigTransaction::TYPE_ENABLE: 78 82 return $object->setIsEnabled($v); 83 + case PhabricatorAuthProviderConfigTransaction::TYPE_LOGIN: 84 + return $object->setShouldAllowLogin($v); 79 85 case PhabricatorAuthProviderConfigTransaction::TYPE_REGISTRATION: 80 86 return $object->setShouldAllowRegistration($v); 81 87 case PhabricatorAuthProviderConfigTransaction::TYPE_LINK: ··· 106 112 $type = $u->getTransactionType(); 107 113 switch ($type) { 108 114 case PhabricatorAuthProviderConfigTransaction::TYPE_ENABLE: 115 + case PhabricatorAuthProviderConfigTransaction::TYPE_LOGIN: 109 116 case PhabricatorAuthProviderConfigTransaction::TYPE_REGISTRATION: 110 117 case PhabricatorAuthProviderConfigTransaction::TYPE_LINK: 111 118 case PhabricatorAuthProviderConfigTransaction::TYPE_UNLINK:
+4
src/applications/auth/provider/PhabricatorAuthProvider.php
··· 121 121 } 122 122 123 123 public function shouldAllowRegistration() { 124 + if (!$this->shouldAllowLogin()) { 125 + return false; 126 + } 127 + 124 128 return $this->getProviderConfig()->getShouldAllowRegistration(); 125 129 } 126 130
+12
src/applications/auth/storage/PhabricatorAuthProviderConfigTransaction.php
··· 4 4 extends PhabricatorApplicationTransaction { 5 5 6 6 const TYPE_ENABLE = 'config:enable'; 7 + const TYPE_LOGIN = 'config:login'; 7 8 const TYPE_REGISTRATION = 'config:registration'; 8 9 const TYPE_LINK = 'config:link'; 9 10 const TYPE_UNLINK = 'config:unlink'; ··· 87 88 } else { 88 89 return pht( 89 90 '%s disabled this provider.', 91 + $this->renderHandleLink($author_phid)); 92 + } 93 + break; 94 + case self::TYPE_LOGIN: 95 + if ($new) { 96 + return pht( 97 + '%s enabled login.', 98 + $this->renderHandleLink($author_phid)); 99 + } else { 100 + return pht( 101 + '%s disabled login.', 90 102 $this->renderHandleLink($author_phid)); 91 103 } 92 104 break;