Page MenuHomePhabricator

D9150.id21746.diff
No OneTemporary

D9150.id21746.diff

diff --git a/resources/sql/autopatches/20141505.trustEmails.sql b/resources/sql/autopatches/20141505.trustEmails.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20141505.trustEmails.sql
@@ -0,0 +1,2 @@
+ALTER TABLE {$NAMESPACE}_auth.auth_providerconfig
+ ADD `shouldTrustEmails` tinyint(1) NOT NULL DEFAULT 0 AFTER shouldAllowUnlink;
diff --git a/src/applications/auth/controller/PhabricatorAuthRegisterController.php b/src/applications/auth/controller/PhabricatorAuthRegisterController.php
--- a/src/applications/auth/controller/PhabricatorAuthRegisterController.php
+++ b/src/applications/auth/controller/PhabricatorAuthRegisterController.php
@@ -249,6 +249,11 @@
($value_email === $default_email);
}
+ if (($provider->shouldTrustEmails()) &&
+ (empty($default_email) || $value_email === $default_email)) {
+ $verify_email = true;
+ }
+
$email_obj = id(new PhabricatorUserEmail())
->setAddress($value_email)
->setIsVerified((int)$verify_email);
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
@@ -85,6 +85,7 @@
$v_registration = $config->getShouldAllowRegistration();
$v_link = $config->getShouldAllowLink();
$v_unlink = $config->getShouldAllowUnlink();
+ $v_trust_email = $config->getShouldTrustEmails();
if ($request->isFormPost()) {
@@ -120,6 +121,11 @@
PhabricatorAuthProviderConfigTransaction::TYPE_UNLINK)
->setNewValue($request->getInt('allowUnlink', 0));
+ $xactions[] = id(new PhabricatorAuthProviderConfigTransaction())
+ ->setTransactionType(
+ PhabricatorAuthProviderConfigTransaction::TYPE_TRUST_EMAILS)
+ ->setNewValue($request->getInt('trustEmails', 0));
+
foreach ($properties as $key => $value) {
$xactions[] = id(new PhabricatorAuthProviderConfigTransaction())
->setTransactionType(
@@ -212,6 +218,13 @@
'existing Phabricator accounts. If you disable this, Phabricator '.
'accounts will be permanently bound to provider accounts.'));
+ $str_trusted_email = hsprintf(
+ '<strong>%s:</strong> %s',
+ pht('Trust Email Addresses'),
+ pht(
+ 'Phabricator will skip email verification for accounts registered '.
+ 'through this provider.'));
+
$status_tag = id(new PHUITagView())
->setType(PHUITagView::TYPE_STATE);
if ($is_new) {
@@ -260,7 +273,14 @@
'allowUnlink',
1,
$str_unlink,
- $v_unlink));
+ $v_unlink))
+ ->appendChild(
+ id(new AphrontFormCheckboxControl())
+ ->addCheckbox(
+ 'trustEmails',
+ 1,
+ $str_trusted_email,
+ $v_trust_email));
$provider->extendEditForm($request, $form, $properties, $issues);
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
@@ -10,6 +10,7 @@
$types[] = PhabricatorAuthProviderConfigTransaction::TYPE_REGISTRATION;
$types[] = PhabricatorAuthProviderConfigTransaction::TYPE_LINK;
$types[] = PhabricatorAuthProviderConfigTransaction::TYPE_UNLINK;
+ $types[] = PhabricatorAuthProviderConfigTransaction::TYPE_TRUST_EMAILS;
$types[] = PhabricatorAuthProviderConfigTransaction::TYPE_PROPERTY;
return $types;
@@ -32,6 +33,8 @@
return (int)$object->getShouldAllowLink();
case PhabricatorAuthProviderConfigTransaction::TYPE_UNLINK:
return (int)$object->getShouldAllowUnlink();
+ case PhabricatorAuthProviderConfigTransaction::TYPE_UNLINK:
+ return (int)$object->getShouldTrustEmails();
case PhabricatorAuthProviderConfigTransaction::TYPE_PROPERTY:
$key = $xaction->getMetadataValue(
PhabricatorAuthProviderConfigTransaction::PROPERTY_KEY);
@@ -48,6 +51,7 @@
case PhabricatorAuthProviderConfigTransaction::TYPE_REGISTRATION:
case PhabricatorAuthProviderConfigTransaction::TYPE_LINK:
case PhabricatorAuthProviderConfigTransaction::TYPE_UNLINK:
+ case PhabricatorAuthProviderConfigTransaction::TYPE_TRUST_EMAILS:
case PhabricatorAuthProviderConfigTransaction::TYPE_PROPERTY:
return $xaction->getNewValue();
}
@@ -66,6 +70,8 @@
return $object->setShouldAllowLink($v);
case PhabricatorAuthProviderConfigTransaction::TYPE_UNLINK:
return $object->setShouldAllowUnlink($v);
+ case PhabricatorAuthProviderConfigTransaction::TYPE_TRUST_EMAILS:
+ return $object->setShouldTrustEmails($v);
case PhabricatorAuthProviderConfigTransaction::TYPE_PROPERTY:
$key = $xaction->getMetadataValue(
PhabricatorAuthProviderConfigTransaction::PROPERTY_KEY);
@@ -89,6 +95,7 @@
case PhabricatorAuthProviderConfigTransaction::TYPE_REGISTRATION:
case PhabricatorAuthProviderConfigTransaction::TYPE_LINK:
case PhabricatorAuthProviderConfigTransaction::TYPE_UNLINK:
+ case PhabricatorAuthProviderConfigTransaction::TYPE_TRUST_EMAILS:
// For these types, last transaction wins.
return $v;
}
diff --git a/src/applications/auth/provider/PhabricatorAuthProvider.php b/src/applications/auth/provider/PhabricatorAuthProvider.php
--- a/src/applications/auth/provider/PhabricatorAuthProvider.php
+++ b/src/applications/auth/provider/PhabricatorAuthProvider.php
@@ -141,6 +141,10 @@
return $this->getProviderConfig()->getShouldAllowUnlink();
}
+ public function shouldTrustEmails() {
+ return $this->getProviderConfig()->getShouldTrustEmails();
+ }
+
public function buildLoginForm(
PhabricatorAuthStartController $controller) {
return $this->renderLoginForm($controller->getRequest(), $mode = 'start');
diff --git a/src/applications/auth/storage/PhabricatorAuthProviderConfig.php b/src/applications/auth/storage/PhabricatorAuthProviderConfig.php
--- a/src/applications/auth/storage/PhabricatorAuthProviderConfig.php
+++ b/src/applications/auth/storage/PhabricatorAuthProviderConfig.php
@@ -12,6 +12,7 @@
protected $shouldAllowRegistration = 0;
protected $shouldAllowLink = 0;
protected $shouldAllowUnlink = 0;
+ protected $shouldTrustEmails = 0;
protected $properties = array();
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
@@ -7,6 +7,7 @@
const TYPE_REGISTRATION = 'config:registration';
const TYPE_LINK = 'config:link';
const TYPE_UNLINK = 'config:unlink';
+ const TYPE_TRUST_EMAILS = "config:trustEmails";
const TYPE_PROPERTY = 'config:property';
const PROPERTY_KEY = 'auth:property';
@@ -121,6 +122,17 @@
$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_PROPERTY:
$provider = $this->getProvider();
if ($provider) {

File Metadata

Mime Type
text/plain
Expires
Sun, May 19, 5:03 PM (4 w, 5 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6302500
Default Alt Text
D9150.id21746.diff (7 KB)

Event Timeline