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

Remove an ancient no-op check for duplicated external accounts

Summary:
Ref T13493. This check was introduced in D4647, but the condition can never be reached in modern Phabricator because the table has a unique key on `<accountType, accountDomain, accountID>` -- so no row can ever exist with the same value for that tuple but a different ID.

(I'm not entirely sure if it was reachable in D4647 either.)

Test Plan: Used `SHOW CREATE TABLE` to look at keys on the table and reasoned that this block can never have any effect.

Maniphest Tasks: T13493

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

+28 -23
+28 -7
src/applications/auth/adapter/PhutilAuthAdapter.php
··· 2 2 3 3 /** 4 4 * Abstract interface to an identity provider or authentication source, like 5 - * Twitter, Facebook or Google. 5 + * Twitter, Facebook, or Google. 6 6 * 7 7 * Generally, adapters are handed some set of credentials particular to the 8 8 * provider they adapt, and they turn those credentials into standard ··· 17 17 */ 18 18 abstract class PhutilAuthAdapter extends Phobject { 19 19 20 + final public function getAccountIdentifiers() { 21 + $result = $this->newAccountIdentifiers(); 22 + assert_instances_of($result, 'PhabricatorExternalAccountIdentifier'); 23 + return $result; 24 + } 25 + 26 + protected function newAccountIdentifiers() { 27 + $identifiers = array(); 28 + 29 + $raw_identifier = $this->getAccountID(); 30 + if ($raw_identifier !== null) { 31 + $identifiers[] = $this->newAccountIdentifier($raw_identifier); 32 + } 33 + 34 + return $identifiers; 35 + } 36 + 20 37 /** 21 - * Get a unique identifier associated with the identity. For most providers, 22 - * this is an account ID. 38 + * Get a unique identifier associated with the account. 39 + * 40 + * This identifier should be permanent, immutable, and uniquely identify 41 + * the account. If possible, it should be nonsensitive. For providers that 42 + * have a GUID or PHID value for accounts, these are the best values to use. 23 43 * 24 - * The account ID needs to be unique within this adapter's configuration, such 25 - * that `<adapterKey, accountID>` is globally unique and always identifies the 26 - * same identity. 44 + * You can implement @{method:newAccountIdentifiers} instead if a provider 45 + * is unable to emit identifiers with all of these properties. 27 46 * 28 47 * If the adapter was unable to authenticate an identity, it should return 29 48 * `null`. ··· 31 50 * @return string|null Unique account identifier, or `null` if authentication 32 51 * failed. 33 52 */ 34 - abstract public function getAccountID(); 53 + public function getAccountID() { 54 + throw new PhutilMethodNotImplementedException(); 55 + } 35 56 36 57 37 58 /**
-16
src/applications/auth/controller/PhabricatorAuthController.php
··· 197 197 return array($account, $provider, $response); 198 198 } 199 199 200 - $other_account = id(new PhabricatorExternalAccount())->loadAllWhere( 201 - 'accountType = %s AND accountDomain = %s AND accountID = %s 202 - AND id != %d', 203 - $account->getAccountType(), 204 - $account->getAccountDomain(), 205 - $account->getAccountID(), 206 - $account->getID()); 207 - 208 - if ($other_account) { 209 - $response = $this->renderError( 210 - pht( 211 - 'The account you are attempting to register with already belongs '. 212 - 'to another user.')); 213 - return array($account, $provider, $response); 214 - } 215 - 216 200 $config = $account->getProviderConfig(); 217 201 if (!$config->getIsEnabled()) { 218 202 $response = $this->renderError(