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

Prevent duplicate account links from being created by swapping logins and then refreshing the link

Summary:
Fixes T6707. Users can currently do this:

- Log in to a service (like Facebook or Google) with account "A".
- Link their Phabricator account to that account.
- Log out of Facebook, log back in with account "B".
- Refresh the account link from {nav Settings > External Accounts}.

When they do this, we write a second account link (between their Phabricator account and account "B"). However, the rest of the codebase assumes accounts are singly-linked, so this breaks down elsewhere.

For now, decline to link the second account. We'll permit this some day, but need to do more work to allow it, and the need is very rare.

Test Plan:
- Followed the steps above, hit the new error.
- Logged back in to the proper account and did a link refresh (which worked).

{F905562}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T6707

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

+21
+21
src/applications/auth/controller/PhabricatorAuthLoginController.php
··· 113 113 $provider->getProviderName())); 114 114 } 115 115 } else { 116 + 117 + // If the user already has a linked account of this type, prevent them 118 + // from linking a second account. This can happen if they swap logins 119 + // and then refresh the account link. See T6707. We will eventually 120 + // allow this after T2549. 121 + $existing_accounts = id(new PhabricatorExternalAccountQuery()) 122 + ->setViewer($viewer) 123 + ->withUserPHIDs(array($viewer->getPHID())) 124 + ->withAccountTypes(array($account->getAccountType())) 125 + ->execute(); 126 + if ($existing_accounts) { 127 + return $this->renderError( 128 + pht( 129 + 'Your Phabricator account is already connected to an external '. 130 + 'account on this provider ("%s"), but you are currently logged '. 131 + 'in to the provider with a different account. Log out of the '. 132 + 'external service, then log back in with the correct account '. 133 + 'before refreshing the account link.', 134 + $provider->getProviderName())); 135 + } 136 + 116 137 if ($provider->shouldAllowAccountLink()) { 117 138 return $this->processLinkUser($account); 118 139 } else {