Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15445387
D20659.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
27 KB
Referenced Files
None
Subscribers
None
D20659.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -2241,6 +2241,15 @@
'PhabricatorAuthChangePasswordAction' => 'applications/auth/action/PhabricatorAuthChangePasswordAction.php',
'PhabricatorAuthConduitAPIMethod' => 'applications/auth/conduit/PhabricatorAuthConduitAPIMethod.php',
'PhabricatorAuthConduitTokenRevoker' => 'applications/auth/revoker/PhabricatorAuthConduitTokenRevoker.php',
+ 'PhabricatorAuthConfigAutoLoginTransaction' => 'applications/auth/xaction/PhabricatorAuthConfigAutoLoginTransaction.php',
+ 'PhabricatorAuthConfigEnableTransaction' => 'applications/auth/xaction/PhabricatorAuthConfigEnableTransaction.php',
+ 'PhabricatorAuthConfigLinkTransaction' => 'applications/auth/xaction/PhabricatorAuthConfigLinkTransaction.php',
+ 'PhabricatorAuthConfigLoginTransaction' => 'applications/auth/xaction/PhabricatorAuthConfigLoginTransaction.php',
+ 'PhabricatorAuthConfigPropertyTransaction' => 'applications/auth/xaction/PhabricatorAuthConfigPropertyTransaction.php',
+ 'PhabricatorAuthConfigRegistrationTransaction' => 'applications/auth/xaction/PhabricatorAuthConfigRegistrationTransaction.php',
+ 'PhabricatorAuthConfigTransactionType' => 'applications/auth/xaction/PhabricatorAuthConfigTransactionType.php',
+ 'PhabricatorAuthConfigTrustEmailsTransaction' => 'applications/auth/xaction/PhabricatorAuthConfigTrustEmailsTransaction.php',
+ 'PhabricatorAuthConfigUnlinkTransaction' => 'applications/auth/xaction/PhabricatorAuthConfigUnlinkTransaction.php',
'PhabricatorAuthConfirmLinkController' => 'applications/auth/controller/PhabricatorAuthConfirmLinkController.php',
'PhabricatorAuthContactNumber' => 'applications/auth/storage/PhabricatorAuthContactNumber.php',
'PhabricatorAuthContactNumberController' => 'applications/auth/controller/contact/PhabricatorAuthContactNumberController.php',
@@ -8187,6 +8196,15 @@
'PhabricatorAuthChangePasswordAction' => 'PhabricatorSystemAction',
'PhabricatorAuthConduitAPIMethod' => 'ConduitAPIMethod',
'PhabricatorAuthConduitTokenRevoker' => 'PhabricatorAuthRevoker',
+ 'PhabricatorAuthConfigAutoLoginTransaction' => 'PhabricatorAuthConfigTransactionType',
+ 'PhabricatorAuthConfigEnableTransaction' => 'PhabricatorAuthConfigTransactionType',
+ 'PhabricatorAuthConfigLinkTransaction' => 'PhabricatorAuthConfigTransactionType',
+ 'PhabricatorAuthConfigLoginTransaction' => 'PhabricatorAuthConfigTransactionType',
+ 'PhabricatorAuthConfigPropertyTransaction' => 'PhabricatorAuthConfigTransactionType',
+ 'PhabricatorAuthConfigRegistrationTransaction' => 'PhabricatorAuthConfigTransactionType',
+ 'PhabricatorAuthConfigTransactionType' => 'PhabricatorModularTransactionType',
+ 'PhabricatorAuthConfigTrustEmailsTransaction' => 'PhabricatorAuthConfigTransactionType',
+ 'PhabricatorAuthConfigUnlinkTransaction' => 'PhabricatorAuthConfigTransactionType',
'PhabricatorAuthConfirmLinkController' => 'PhabricatorAuthController',
'PhabricatorAuthContactNumber' => array(
'PhabricatorAuthDAO',
@@ -8355,7 +8373,7 @@
'PhabricatorAuthProviderConfigController' => 'PhabricatorAuthProviderController',
'PhabricatorAuthProviderConfigEditor' => 'PhabricatorApplicationTransactionEditor',
'PhabricatorAuthProviderConfigQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
- 'PhabricatorAuthProviderConfigTransaction' => 'PhabricatorApplicationTransaction',
+ 'PhabricatorAuthProviderConfigTransaction' => 'PhabricatorModularTransaction',
'PhabricatorAuthProviderConfigTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
'PhabricatorAuthProviderController' => 'PhabricatorAuthController',
'PhabricatorAuthProviderViewController' => 'PhabricatorAuthProviderConfigController',
diff --git a/src/applications/auth/controller/config/PhabricatorAuthDisableController.php b/src/applications/auth/controller/config/PhabricatorAuthDisableController.php
--- a/src/applications/auth/controller/config/PhabricatorAuthDisableController.php
+++ b/src/applications/auth/controller/config/PhabricatorAuthDisableController.php
@@ -32,7 +32,7 @@
$xactions[] = id(new PhabricatorAuthProviderConfigTransaction())
->setTransactionType(
- PhabricatorAuthProviderConfigTransaction::TYPE_ENABLE)
+ PhabricatorAuthConfigEnableTransaction::TRANSACTIONTYPE)
->setNewValue((int)$is_enable);
$editor = id(new PhabricatorAuthProviderConfigEditor())
diff --git a/src/applications/auth/controller/config/PhabricatorAuthEditController.php b/src/applications/auth/controller/config/PhabricatorAuthEditController.php
--- a/src/applications/auth/controller/config/PhabricatorAuthEditController.php
+++ b/src/applications/auth/controller/config/PhabricatorAuthEditController.php
@@ -109,40 +109,42 @@
$xactions[] = id(new PhabricatorAuthProviderConfigTransaction())
->setTransactionType(
- PhabricatorAuthProviderConfigTransaction::TYPE_LOGIN)
+ PhabricatorAuthConfigLoginTransaction::TRANSACTIONTYPE)
->setNewValue($request->getInt('allowLogin', 0));
$xactions[] = id(new PhabricatorAuthProviderConfigTransaction())
->setTransactionType(
- PhabricatorAuthProviderConfigTransaction::TYPE_REGISTRATION)
+ PhabricatorAuthConfigRegistrationTransaction::TRANSACTIONTYPE)
->setNewValue($request->getInt('allowRegistration', 0));
$xactions[] = id(new PhabricatorAuthProviderConfigTransaction())
->setTransactionType(
- PhabricatorAuthProviderConfigTransaction::TYPE_LINK)
+ PhabricatorAuthConfigLinkTransaction::TRANSACTIONTYPE)
->setNewValue($request->getInt('allowLink', 0));
$xactions[] = id(new PhabricatorAuthProviderConfigTransaction())
->setTransactionType(
- PhabricatorAuthProviderConfigTransaction::TYPE_UNLINK)
+ PhabricatorAuthConfigUnlinkTransaction::TRANSACTIONTYPE)
->setNewValue($request->getInt('allowUnlink', 0));
- $xactions[] = id(new PhabricatorAuthProviderConfigTransaction())
- ->setTransactionType(
- PhabricatorAuthProviderConfigTransaction::TYPE_TRUST_EMAILS)
- ->setNewValue($request->getInt('trustEmails', 0));
+ if ($provider->shouldAllowEmailTrustConfiguration()) {
+ $xactions[] = id(new PhabricatorAuthProviderConfigTransaction())
+ ->setTransactionType(
+ PhabricatorAuthConfigTrustEmailsTransaction::TRANSACTIONTYPE)
+ ->setNewValue($request->getInt('trustEmails', 0));
+ }
if ($provider->supportsAutoLogin()) {
$xactions[] = id(new PhabricatorAuthProviderConfigTransaction())
->setTransactionType(
- PhabricatorAuthProviderConfigTransaction::TYPE_AUTO_LOGIN)
+ PhabricatorAuthConfigAutoLoginTransaction::TRANSACTIONTYPE)
->setNewValue($request->getInt('autoLogin', 0));
}
foreach ($properties as $key => $value) {
$xactions[] = id(new PhabricatorAuthProviderConfigTransaction())
->setTransactionType(
- PhabricatorAuthProviderConfigTransaction::TYPE_PROPERTY)
+ PhabricatorAuthConfigPropertyTransaction::TRANSACTIONTYPE)
->setMetadataValue('auth:property', $key)
->setNewValue($value);
}
diff --git a/src/applications/auth/editor/PhabricatorAuthProviderConfigEditor.php b/src/applications/auth/editor/PhabricatorAuthProviderConfigEditor.php
--- a/src/applications/auth/editor/PhabricatorAuthProviderConfigEditor.php
+++ b/src/applications/auth/editor/PhabricatorAuthProviderConfigEditor.php
@@ -11,120 +11,6 @@
return pht('Auth Providers');
}
- public function getTransactionTypes() {
- $types = parent::getTransactionTypes();
-
- $types[] = PhabricatorAuthProviderConfigTransaction::TYPE_ENABLE;
- $types[] = PhabricatorAuthProviderConfigTransaction::TYPE_LOGIN;
- $types[] = PhabricatorAuthProviderConfigTransaction::TYPE_REGISTRATION;
- $types[] = PhabricatorAuthProviderConfigTransaction::TYPE_LINK;
- $types[] = PhabricatorAuthProviderConfigTransaction::TYPE_UNLINK;
- $types[] = PhabricatorAuthProviderConfigTransaction::TYPE_TRUST_EMAILS;
- $types[] = PhabricatorAuthProviderConfigTransaction::TYPE_AUTO_LOGIN;
- $types[] = PhabricatorAuthProviderConfigTransaction::TYPE_PROPERTY;
-
- return $types;
- }
-
- protected function getCustomTransactionOldValue(
- PhabricatorLiskDAO $object,
- PhabricatorApplicationTransaction $xaction) {
-
- switch ($xaction->getTransactionType()) {
- case PhabricatorAuthProviderConfigTransaction::TYPE_ENABLE:
- if ($object->getIsEnabled() === null) {
- return null;
- } else {
- return (int)$object->getIsEnabled();
- }
- case PhabricatorAuthProviderConfigTransaction::TYPE_LOGIN:
- return (int)$object->getShouldAllowLogin();
- case PhabricatorAuthProviderConfigTransaction::TYPE_REGISTRATION:
- return (int)$object->getShouldAllowRegistration();
- case PhabricatorAuthProviderConfigTransaction::TYPE_LINK:
- return (int)$object->getShouldAllowLink();
- case PhabricatorAuthProviderConfigTransaction::TYPE_UNLINK:
- return (int)$object->getShouldAllowUnlink();
- case PhabricatorAuthProviderConfigTransaction::TYPE_TRUST_EMAILS:
- return (int)$object->getShouldTrustEmails();
- case PhabricatorAuthProviderConfigTransaction::TYPE_AUTO_LOGIN:
- return (int)$object->getShouldAutoLogin();
- case PhabricatorAuthProviderConfigTransaction::TYPE_PROPERTY:
- $key = $xaction->getMetadataValue(
- PhabricatorAuthProviderConfigTransaction::PROPERTY_KEY);
- return $object->getProperty($key);
- }
- }
-
- protected function getCustomTransactionNewValue(
- PhabricatorLiskDAO $object,
- PhabricatorApplicationTransaction $xaction) {
-
- switch ($xaction->getTransactionType()) {
- case PhabricatorAuthProviderConfigTransaction::TYPE_ENABLE:
- case PhabricatorAuthProviderConfigTransaction::TYPE_LOGIN:
- case PhabricatorAuthProviderConfigTransaction::TYPE_REGISTRATION:
- case PhabricatorAuthProviderConfigTransaction::TYPE_LINK:
- case PhabricatorAuthProviderConfigTransaction::TYPE_UNLINK:
- case PhabricatorAuthProviderConfigTransaction::TYPE_TRUST_EMAILS:
- case PhabricatorAuthProviderConfigTransaction::TYPE_AUTO_LOGIN:
- case PhabricatorAuthProviderConfigTransaction::TYPE_PROPERTY:
- return $xaction->getNewValue();
- }
- }
-
- protected function applyCustomInternalTransaction(
- PhabricatorLiskDAO $object,
- PhabricatorApplicationTransaction $xaction) {
- $v = $xaction->getNewValue();
- switch ($xaction->getTransactionType()) {
- case PhabricatorAuthProviderConfigTransaction::TYPE_ENABLE:
- return $object->setIsEnabled($v);
- case PhabricatorAuthProviderConfigTransaction::TYPE_LOGIN:
- return $object->setShouldAllowLogin($v);
- case PhabricatorAuthProviderConfigTransaction::TYPE_REGISTRATION:
- return $object->setShouldAllowRegistration($v);
- case PhabricatorAuthProviderConfigTransaction::TYPE_LINK:
- return $object->setShouldAllowLink($v);
- case PhabricatorAuthProviderConfigTransaction::TYPE_UNLINK:
- return $object->setShouldAllowUnlink($v);
- case PhabricatorAuthProviderConfigTransaction::TYPE_TRUST_EMAILS:
- return $object->setShouldTrustEmails($v);
- case PhabricatorAuthProviderConfigTransaction::TYPE_AUTO_LOGIN:
- return $object->setShouldAutoLogin($v);
- case PhabricatorAuthProviderConfigTransaction::TYPE_PROPERTY:
- $key = $xaction->getMetadataValue(
- PhabricatorAuthProviderConfigTransaction::PROPERTY_KEY);
- return $object->setProperty($key, $v);
- }
- }
-
- protected function applyCustomExternalTransaction(
- PhabricatorLiskDAO $object,
- PhabricatorApplicationTransaction $xaction) {
- return;
- }
-
- protected function mergeTransactions(
- PhabricatorApplicationTransaction $u,
- PhabricatorApplicationTransaction $v) {
-
- $type = $u->getTransactionType();
- switch ($type) {
- case PhabricatorAuthProviderConfigTransaction::TYPE_ENABLE:
- case PhabricatorAuthProviderConfigTransaction::TYPE_LOGIN:
- case PhabricatorAuthProviderConfigTransaction::TYPE_REGISTRATION:
- case PhabricatorAuthProviderConfigTransaction::TYPE_LINK:
- case PhabricatorAuthProviderConfigTransaction::TYPE_UNLINK:
- case PhabricatorAuthProviderConfigTransaction::TYPE_TRUST_EMAILS:
- case PhabricatorAuthProviderConfigTransaction::TYPE_AUTO_LOGIN:
- // For these types, last transaction wins.
- return $v;
- }
-
- return parent::mergeTransactions($u, $v);
- }
-
protected function validateAllTransactions(
PhabricatorLiskDAO $object,
array $xactions) {
diff --git a/src/applications/auth/storage/PhabricatorAuthProviderConfigTransaction.php b/src/applications/auth/storage/PhabricatorAuthProviderConfigTransaction.php
--- a/src/applications/auth/storage/PhabricatorAuthProviderConfigTransaction.php
+++ b/src/applications/auth/storage/PhabricatorAuthProviderConfigTransaction.php
@@ -1,16 +1,7 @@
<?php
final class PhabricatorAuthProviderConfigTransaction
- extends PhabricatorApplicationTransaction {
-
- const TYPE_ENABLE = 'config:enable';
- const TYPE_LOGIN = 'config:login';
- const TYPE_REGISTRATION = 'config:registration';
- const TYPE_LINK = 'config:link';
- const TYPE_UNLINK = 'config:unlink';
- const TYPE_TRUST_EMAILS = 'config:trustEmails';
- const TYPE_AUTO_LOGIN = 'config:autoLogin';
- const TYPE_PROPERTY = 'config:property';
+ extends PhabricatorModularTransaction {
const PROPERTY_KEY = 'auth:property';
@@ -26,142 +17,8 @@
return PhabricatorAuthAuthProviderPHIDType::TYPECONST;
}
- public function getIcon() {
- $old = $this->getOldValue();
- $new = $this->getNewValue();
-
- switch ($this->getTransactionType()) {
- case self::TYPE_ENABLE:
- if ($new) {
- return 'fa-check';
- } else {
- return 'fa-ban';
- }
- }
-
- return parent::getIcon();
- }
-
- public function getColor() {
- $old = $this->getOldValue();
- $new = $this->getNewValue();
-
- switch ($this->getTransactionType()) {
- case self::TYPE_ENABLE:
- if ($new) {
- return 'green';
- } else {
- return 'indigo';
- }
- }
-
- return parent::getColor();
- }
-
- public function getTitle() {
- $author_phid = $this->getAuthorPHID();
-
- $old = $this->getOldValue();
- $new = $this->getNewValue();
-
- switch ($this->getTransactionType()) {
- case self::TYPE_ENABLE:
- if ($old === null) {
- return pht(
- '%s created this provider.',
- $this->renderHandleLink($author_phid));
- } else if ($new) {
- return pht(
- '%s enabled this provider.',
- $this->renderHandleLink($author_phid));
- } else {
- return pht(
- '%s disabled this provider.',
- $this->renderHandleLink($author_phid));
- }
- break;
- case self::TYPE_LOGIN:
- if ($new) {
- return pht(
- '%s enabled login.',
- $this->renderHandleLink($author_phid));
- } else {
- return pht(
- '%s disabled login.',
- $this->renderHandleLink($author_phid));
- }
- break;
- case self::TYPE_REGISTRATION:
- if ($new) {
- return pht(
- '%s enabled registration.',
- $this->renderHandleLink($author_phid));
- } else {
- return pht(
- '%s disabled registration.',
- $this->renderHandleLink($author_phid));
- }
- break;
- case self::TYPE_LINK:
- if ($new) {
- return pht(
- '%s enabled account linking.',
- $this->renderHandleLink($author_phid));
- } else {
- return pht(
- '%s disabled account linking.',
- $this->renderHandleLink($author_phid));
- }
- break;
- case self::TYPE_UNLINK:
- if ($new) {
- return pht(
- '%s enabled account unlinking.',
- $this->renderHandleLink($author_phid));
- } else {
- return pht(
- '%s disabled account unlinking.',
- $this->renderHandleLink($author_phid));
- }
- break;
- case self::TYPE_TRUST_EMAILS:
- if ($new) {
- return pht(
- '%s enabled email trust.',
- $this->renderHandleLink($author_phid));
- } else {
- return pht(
- '%s disabled email trust.',
- $this->renderHandleLink($author_phid));
- }
- break;
- case self::TYPE_AUTO_LOGIN:
- if ($new) {
- return pht(
- '%s enabled auto login.',
- $this->renderHandleLink($author_phid));
- } else {
- return pht(
- '%s disabled auto login.',
- $this->renderHandleLink($author_phid));
- }
- break;
- case self::TYPE_PROPERTY:
- $provider = $this->getProvider();
- if ($provider) {
- $title = $provider->renderConfigPropertyTransactionTitle($this);
- if (strlen($title)) {
- return $title;
- }
- }
-
- return pht(
- '%s edited a property of this provider.',
- $this->renderHandleLink($author_phid));
- break;
- }
-
- return parent::getTitle();
+ public function getBaseTransactionClass() {
+ return 'PhabricatorAuthConfigTransactionType';
}
}
diff --git a/src/applications/auth/xaction/PhabricatorAuthConfigAutoLoginTransaction.php b/src/applications/auth/xaction/PhabricatorAuthConfigAutoLoginTransaction.php
new file mode 100644
--- /dev/null
+++ b/src/applications/auth/xaction/PhabricatorAuthConfigAutoLoginTransaction.php
@@ -0,0 +1,44 @@
+<?php
+
+final class PhabricatorAuthConfigAutoLoginTransaction
+ extends PhabricatorAuthConfigTransactionType {
+
+ const TRANSACTIONTYPE = 'config:autoLogin';
+
+ public function generateOldValue($object) {
+ return (int)$object->getShouldAutoLogin();
+ }
+
+ public function applyInternalEffects($object, $value) {
+ $object->setShouldAutoLogin($value);
+ }
+
+ public function getTitle() {
+ if ($this->getNewValue()) {
+ return pht('%s enabled auto login.',
+ $this->renderAuthor());
+ } else {
+ return pht('%s disabled auto login.',
+ $this->renderAuthor());
+ }
+ }
+
+ public function validateTransactions($object, array $xactions) {
+ $errors = array();
+ $provider = $object->getProvider();
+
+ foreach ($xactions as $xaction) {
+ if (!$provider->supportsAutoLogin()) {
+ $errors[] = $this->newInvalidError(
+ pht(
+ 'Authentication provider "%s" does not support auto login.',
+ get_class($provider)),
+ $xaction);
+ continue;
+ }
+ }
+
+ return $errors;
+ }
+
+}
diff --git a/src/applications/auth/xaction/PhabricatorAuthConfigEnableTransaction.php b/src/applications/auth/xaction/PhabricatorAuthConfigEnableTransaction.php
new file mode 100644
--- /dev/null
+++ b/src/applications/auth/xaction/PhabricatorAuthConfigEnableTransaction.php
@@ -0,0 +1,42 @@
+<?php
+
+final class PhabricatorAuthConfigEnableTransaction
+ extends PhabricatorAuthConfigTransactionType {
+
+ const TRANSACTIONTYPE = 'config:enable';
+
+ public function generateOldValue($object) {
+ return (int)$object->getIsEnabled();
+ }
+
+ public function applyInternalEffects($object, $value) {
+ $object->setIsEnabled($value);
+ }
+
+ public function getTitle() {
+ if ($this->getNewValue()) {
+ return pht('%s enabled this provider.',
+ $this->renderAuthor());
+ } else {
+ return pht('%s disabled this provider.',
+ $this->renderAuthor());
+ }
+ }
+
+ public function getIcon() {
+ if ($this->getNewValue()) {
+ return 'fa-check';
+ } else {
+ return 'fa-ban';
+ }
+ }
+
+ public function getColor() {
+ if ($this->getNewValue()) {
+ return 'green';
+ } else {
+ return 'indigo';
+ }
+ }
+
+}
diff --git a/src/applications/auth/xaction/PhabricatorAuthConfigLinkTransaction.php b/src/applications/auth/xaction/PhabricatorAuthConfigLinkTransaction.php
new file mode 100644
--- /dev/null
+++ b/src/applications/auth/xaction/PhabricatorAuthConfigLinkTransaction.php
@@ -0,0 +1,26 @@
+<?php
+
+final class PhabricatorAuthConfigLinkTransaction
+ extends PhabricatorAuthConfigTransactionType {
+
+ const TRANSACTIONTYPE = 'config:link';
+
+ public function generateOldValue($object) {
+ return (int)$object->getShouldAllowLink();
+ }
+
+ public function applyInternalEffects($object, $value) {
+ $object->setShouldAllowLink($value);
+ }
+
+ public function getTitle() {
+ if ($this->getNewValue()) {
+ return pht('%s enabled account linking.',
+ $this->renderAuthor());
+ } else {
+ return pht('%s disabled account linking.',
+ $this->renderAuthor());
+ }
+ }
+
+}
diff --git a/src/applications/auth/xaction/PhabricatorAuthConfigLoginTransaction.php b/src/applications/auth/xaction/PhabricatorAuthConfigLoginTransaction.php
new file mode 100644
--- /dev/null
+++ b/src/applications/auth/xaction/PhabricatorAuthConfigLoginTransaction.php
@@ -0,0 +1,26 @@
+<?php
+
+final class PhabricatorAuthConfigLoginTransaction
+ extends PhabricatorAuthConfigTransactionType {
+
+ const TRANSACTIONTYPE = 'config:login';
+
+ public function generateOldValue($object) {
+ return (int)$object->getShouldAllowLogin();
+ }
+
+ public function applyInternalEffects($object, $value) {
+ $object->setShouldAllowLogin($value);
+ }
+
+ public function getTitle() {
+ if ($this->getNewValue()) {
+ return pht('%s enabled login.',
+ $this->renderAuthor());
+ } else {
+ return pht('%s disabled login.',
+ $this->renderAuthor());
+ }
+ }
+
+}
diff --git a/src/applications/auth/xaction/PhabricatorAuthConfigPropertyTransaction.php b/src/applications/auth/xaction/PhabricatorAuthConfigPropertyTransaction.php
new file mode 100644
--- /dev/null
+++ b/src/applications/auth/xaction/PhabricatorAuthConfigPropertyTransaction.php
@@ -0,0 +1,35 @@
+<?php
+
+final class PhabricatorAuthConfigPropertyTransaction
+ extends PhabricatorAuthConfigTransactionType {
+
+ const TRANSACTIONTYPE = 'config:property';
+
+ public function generateOldValue($object) {
+ $key = $this->getMetadataValue(
+ PhabricatorAuthProviderConfigTransaction::PROPERTY_KEY);
+ return $object->getProperty($key);
+ }
+
+ public function applyInternalEffects($object, $value) {
+ $key = $this->getMetadataValue(
+ PhabricatorAuthProviderConfigTransaction::PROPERTY_KEY);
+ $object->setProperty($key, $value);
+ }
+
+ public function getTitle() {
+ $provider = $this->getObject()->getProvider();
+ if ($provider) {
+ $legacy_xaction = $this->getLegacyUnderlyingTransactionObject();
+ $title = $provider->renderConfigPropertyTransactionTitle($legacy_xaction);
+ if (strlen($title)) {
+ return $title;
+ }
+ }
+
+ return pht(
+ '%s edited a property of this provider.',
+ $this->renderAuthor());
+ }
+
+}
diff --git a/src/applications/auth/xaction/PhabricatorAuthConfigRegistrationTransaction.php b/src/applications/auth/xaction/PhabricatorAuthConfigRegistrationTransaction.php
new file mode 100644
--- /dev/null
+++ b/src/applications/auth/xaction/PhabricatorAuthConfigRegistrationTransaction.php
@@ -0,0 +1,26 @@
+<?php
+
+final class PhabricatorAuthConfigRegistrationTransaction
+ extends PhabricatorAuthConfigTransactionType {
+
+ const TRANSACTIONTYPE = 'config:registration';
+
+ public function generateOldValue($object) {
+ return (int)$object->getShouldAllowRegistration();
+ }
+
+ public function applyInternalEffects($object, $value) {
+ $object->setShouldAllowRegistration($value);
+ }
+
+ public function getTitle() {
+ if ($this->getNewValue()) {
+ return pht('%s enabled registration.',
+ $this->renderAuthor());
+ } else {
+ return pht('%s disabled registration.',
+ $this->renderAuthor());
+ }
+ }
+
+}
diff --git a/src/applications/auth/xaction/PhabricatorAuthConfigTransactionType.php b/src/applications/auth/xaction/PhabricatorAuthConfigTransactionType.php
new file mode 100644
--- /dev/null
+++ b/src/applications/auth/xaction/PhabricatorAuthConfigTransactionType.php
@@ -0,0 +1,4 @@
+<?php
+
+abstract class PhabricatorAuthConfigTransactionType
+ extends PhabricatorModularTransactionType {}
diff --git a/src/applications/auth/xaction/PhabricatorAuthConfigTrustEmailsTransaction.php b/src/applications/auth/xaction/PhabricatorAuthConfigTrustEmailsTransaction.php
new file mode 100644
--- /dev/null
+++ b/src/applications/auth/xaction/PhabricatorAuthConfigTrustEmailsTransaction.php
@@ -0,0 +1,44 @@
+<?php
+
+final class PhabricatorAuthConfigTrustEmailsTransaction
+ extends PhabricatorAuthConfigTransactionType {
+
+ const TRANSACTIONTYPE = 'config:trustEmails';
+
+ public function generateOldValue($object) {
+ return (int)$object->getShouldTrustEmails();
+ }
+
+ public function applyInternalEffects($object, $value) {
+ $object->setShouldTrustEmails($value);
+ }
+
+ public function getTitle() {
+ if ($this->getNewValue()) {
+ return pht('%s enabled email trust.',
+ $this->renderAuthor());
+ } else {
+ return pht('%s disabled email trust.',
+ $this->renderAuthor());
+ }
+ }
+
+ public function validateTransactions($object, array $xactions) {
+ $errors = array();
+ $provider = $object->getProvider();
+
+ foreach ($xactions as $xaction) {
+ if (!$provider->shouldAllowEmailTrustConfiguration()) {
+ $errors[] = $this->newInvalidError(
+ pht(
+ 'Authentication provider "%s" does not support trusting emails.',
+ get_class($provider)),
+ $xaction);
+ continue;
+ }
+ }
+
+ return $errors;
+ }
+
+}
diff --git a/src/applications/auth/xaction/PhabricatorAuthConfigUnlinkTransaction.php b/src/applications/auth/xaction/PhabricatorAuthConfigUnlinkTransaction.php
new file mode 100644
--- /dev/null
+++ b/src/applications/auth/xaction/PhabricatorAuthConfigUnlinkTransaction.php
@@ -0,0 +1,26 @@
+<?php
+
+final class PhabricatorAuthConfigUnlinkTransaction
+ extends PhabricatorAuthConfigTransactionType {
+
+ const TRANSACTIONTYPE = 'config:unlink';
+
+ public function generateOldValue($object) {
+ return (int)$object->getShouldAllowUnlink();
+ }
+
+ public function applyInternalEffects($object, $value) {
+ $object->setShouldAllowUnlink($value);
+ }
+
+ public function getTitle() {
+ if ($this->getNewValue()) {
+ return pht('%s enabled account unlinking.',
+ $this->renderAuthor());
+ } else {
+ return pht('%s disabled account unlinking.',
+ $this->renderAuthor());
+ }
+ }
+
+}
diff --git a/src/applications/transactions/storage/PhabricatorModularTransactionType.php b/src/applications/transactions/storage/PhabricatorModularTransactionType.php
--- a/src/applications/transactions/storage/PhabricatorModularTransactionType.php
+++ b/src/applications/transactions/storage/PhabricatorModularTransactionType.php
@@ -116,6 +116,13 @@
return $this->storage;
}
+ // TODO: This is a temporary hack to modularize authentication provider
+ // configuration without changing the method signature of
+ // PhabricatorAuthProvider->renderConfigPropertyTransactionTitle()
+ protected function getLegacyUnderlyingTransactionObject() {
+ return $this->getStorage();
+ }
+
final public function setViewer(PhabricatorUser $viewer) {
$this->viewer = $viewer;
return $this;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Mar 28, 1:39 PM (3 w, 5 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7692078
Default Alt Text
D20659.diff (27 KB)
Attached To
Mode
D20659: Modularize auth provider configuration
Attached
Detach File
Event Timeline
Log In to Comment