@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.

Show edit transactions for AuthProviders

Summary: Ref T1536. When auth providers are edited, show the edit history.

Test Plan: {F46400}

Reviewers: btrahan

Reviewed By: btrahan

CC: aran, chad

Maniphest Tasks: T1536

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

+158 -13
+17 -7
src/applications/auth/controller/config/PhabricatorAuthEditController.php
··· 15 15 $request = $this->getRequest(); 16 16 $viewer = $request->getUser(); 17 17 18 - $provider = null; 19 18 if ($this->configID) { 20 19 $config = id(new PhabricatorAuthProviderConfigQuery()) 21 20 ->setViewer($viewer) ··· 27 26 ->withIDs(array($this->configID)) 28 27 ->executeOne(); 29 28 if (!$config) { 29 + return new Aphront404Response(); 30 + } 31 + 32 + $provider = $config->getProvider(); 33 + if (!$provider) { 30 34 return new Aphront404Response(); 31 35 } 32 36 ··· 88 92 $xactions[] = id(new PhabricatorAuthProviderConfigTransaction()) 89 93 ->setTransactionType( 90 94 PhabricatorAuthProviderConfigTransaction::TYPE_REGISTRATION) 91 - ->setNewValue($request->getInt('allowRegistration')); 95 + ->setNewValue($request->getInt('allowRegistration', 0)); 92 96 93 97 $xactions[] = id(new PhabricatorAuthProviderConfigTransaction()) 94 98 ->setTransactionType( 95 99 PhabricatorAuthProviderConfigTransaction::TYPE_LINK) 96 - ->setNewValue($request->getInt('allowLink')); 100 + ->setNewValue($request->getInt('allowLink', 0)); 97 101 98 102 $xactions[] = id(new PhabricatorAuthProviderConfigTransaction()) 99 103 ->setTransactionType( 100 104 PhabricatorAuthProviderConfigTransaction::TYPE_UNLINK) 101 - ->setNewValue($request->getInt('allowUnlink')); 105 + ->setNewValue($request->getInt('allowUnlink', 0)); 102 106 103 107 if (!$errors) { 104 108 $editor = id(new PhabricatorAuthProviderConfigEditor()) ··· 199 203 200 204 $xaction_view = null; 201 205 if (!$is_new) { 202 - $xactions = id(new PhabricatorAuthProviderConfigTransactionQuery()); 203 - // TOOD: ... 206 + $xactions = id(new PhabricatorAuthProviderConfigTransactionQuery()) 207 + ->withObjectPHIDs(array($config->getPHID())) 208 + ->setViewer($viewer) 209 + ->execute(); 210 + 211 + $xaction_view = id(new PhabricatorApplicationTransactionView()) 212 + ->setUser($viewer) 213 + ->setTransactions($xactions); 204 214 } 205 215 206 216 return $this->buildApplicationPage( ··· 208 218 $crumbs, 209 219 $errors, 210 220 $form, 211 - $xaction_view 221 + $xaction_view, 212 222 ), 213 223 array( 214 224 'title' => $title,
+8 -5
src/applications/auth/editor/PhabricatorAuthProviderConfigEditor.php
··· 21 21 22 22 switch ($xaction->getTransactionType()) { 23 23 case PhabricatorAuthProviderConfigTransaction::TYPE_ENABLE: 24 - return $object->getIsEnabled(); 24 + if ($object->getIsEnabled() === null) { 25 + return null; 26 + } else { 27 + return (int)$object->getIsEnabled(); 28 + } 25 29 case PhabricatorAuthProviderConfigTransaction::TYPE_REGISTRATION: 26 - return $object->getShouldAllowRegistration(); 30 + return (int)$object->getShouldAllowRegistration(); 27 31 case PhabricatorAuthProviderConfigTransaction::TYPE_LINK: 28 - return $object->getShouldAllowLink(); 32 + return (int)$object->getShouldAllowLink(); 29 33 case PhabricatorAuthProviderConfigTransaction::TYPE_UNLINK: 30 - return $object->getShouldAllowUnlink(); 34 + return (int)$object->getShouldAllowUnlink(); 31 35 case PhabricatorAuthProviderConfigTransaction::TYPE_PROPERTY: 32 36 // TODO 33 37 throw new Exception("TODO"); ··· 51 55 protected function applyCustomInternalTransaction( 52 56 PhabricatorLiskDAO $object, 53 57 PhabricatorApplicationTransaction $xaction) { 54 - 55 58 $v = $xaction->getNewValue(); 56 59 switch ($xaction->getTransactionType()) { 57 60 case PhabricatorAuthProviderConfigTransaction::TYPE_ENABLE:
+15
src/applications/auth/provider/PhabricatorAuthProvider.php
··· 2 2 3 3 abstract class PhabricatorAuthProvider { 4 4 5 + private $providerConfig; 6 + 7 + public function attachProviderConfig(PhabricatorAuthProviderConfig $config) { 8 + $this->providerConfig = $config; 9 + return $this; 10 + } 11 + 12 + public function getProviderConfig() { 13 + if ($this->config === null) { 14 + throw new Exception( 15 + "Call attachProviderConfig() before getProviderConfig()!"); 16 + } 17 + return $this->config; 18 + } 19 + 5 20 public function getNameForCreate() { 6 21 return $this->getProviderName(); 7 22 }
+20 -1
src/applications/auth/storage/PhabricatorAuthProviderConfig.php
··· 7 7 protected $providerType; 8 8 protected $providerDomain; 9 9 10 - protected $isEnabled = 0; 10 + protected $isEnabled; 11 11 protected $shouldAllowLogin = 0; 12 12 protected $shouldAllowRegistration = 0; 13 13 protected $shouldAllowLink = 0; 14 14 protected $shouldAllowUnlink = 0; 15 15 16 16 protected $properties = array(); 17 + 18 + private $provider; 17 19 18 20 public function generatePHID() { 19 21 return PhabricatorPHID::generateNewPHID( ··· 36 38 public function setProperty($key, $value) { 37 39 $this->properties[$key] = $value; 38 40 return $this; 41 + } 42 + 43 + public function getProvider() { 44 + if (!$this->provider) { 45 + $base = PhabricatorAuthProvider::getAllBaseProviders(); 46 + $found = null; 47 + foreach ($base as $provider) { 48 + if (get_class($provider) == $this->providerClass) { 49 + $found = $provider; 50 + break; 51 + } 52 + } 53 + if ($found) { 54 + $this->provider = id(clone $found)->attachProviderConfig($this); 55 + } 56 + } 57 + return $this->provider; 39 58 } 40 59 41 60
+98
src/applications/auth/storage/PhabricatorAuthProviderConfigTransaction.php
··· 25 25 return pht('authentication provider'); 26 26 } 27 27 28 + public function getIcon() { 29 + $old = $this->getOldValue(); 30 + $new = $this->getNewValue(); 31 + 32 + switch ($this->getTransactionType()) { 33 + case self::TYPE_ENABLE: 34 + if ($new) { 35 + return 'new'; 36 + } else { 37 + return 'delete'; 38 + } 39 + } 40 + 41 + return parent::getIcon(); 42 + } 43 + 44 + public function getColor() { 45 + $old = $this->getOldValue(); 46 + $new = $this->getNewValue(); 47 + 48 + switch ($this->getTransactionType()) { 49 + case self::TYPE_ENABLE: 50 + if ($new) { 51 + return 'green'; 52 + } else { 53 + return 'red'; 54 + } 55 + } 56 + 57 + return parent::getColor(); 58 + } 59 + 60 + public function getTitle() { 61 + $author_phid = $this->getAuthorPHID(); 62 + 63 + $old = $this->getOldValue(); 64 + $new = $this->getNewValue(); 65 + 66 + switch ($this->getTransactionType()) { 67 + case self::TYPE_ENABLE: 68 + if ($old === null) { 69 + return pht( 70 + '%s created this provider.', 71 + $this->renderHandleLink($author_phid)); 72 + } else if ($new) { 73 + return pht( 74 + '%s enabled this provider.', 75 + $this->renderHandleLink($author_phid)); 76 + } else { 77 + return pht( 78 + '%s disabled this provider.', 79 + $this->renderHandleLink($author_phid)); 80 + } 81 + break; 82 + case self::TYPE_REGISTRATION: 83 + if ($new) { 84 + return pht( 85 + '%s enabled registration.', 86 + $this->renderHandleLink($author_phid)); 87 + } else { 88 + return pht( 89 + '%s disabled registration.', 90 + $this->renderHandleLink($author_phid)); 91 + } 92 + break; 93 + case self::TYPE_LINK: 94 + if ($new) { 95 + return pht( 96 + '%s enabled accont linking.', 97 + $this->renderHandleLink($author_phid)); 98 + } else { 99 + return pht( 100 + '%s disabled account linking.', 101 + $this->renderHandleLink($author_phid)); 102 + } 103 + break; 104 + case self::TYPE_UNLINK: 105 + if ($new) { 106 + return pht( 107 + '%s enabled account unlinking.', 108 + $this->renderHandleLink($author_phid)); 109 + } else { 110 + return pht( 111 + '%s disabled account unlinking.', 112 + $this->renderHandleLink($author_phid)); 113 + } 114 + break; 115 + case self::TYPE_PROPERTY: 116 + // TODO 117 + return pht( 118 + '%s edited a property of this provider.', 119 + $this->renderHandleLink($author_phid)); 120 + break; 121 + } 122 + 123 + return parent::getTitle(); 124 + } 125 + 28 126 } 29 127