Changeset View
Changeset View
Standalone View
Standalone View
src/applications/auth/controller/PhabricatorAuthLoginController.php
Show First 20 Lines • Show All 107 Lines • ▼ Show 20 Lines | if ($account->getUserPHID()) { | ||||
return $this->renderError( | return $this->renderError( | ||||
pht( | pht( | ||||
'The external account ("%s") you just authenticated with is '. | 'The external account ("%s") you just authenticated with is '. | ||||
'not configured to allow registration on this Phabricator '. | 'not configured to allow registration on this Phabricator '. | ||||
'install. An administrator may have recently disabled it.', | 'install. An administrator may have recently disabled it.', | ||||
$provider->getProviderName())); | $provider->getProviderName())); | ||||
} | } | ||||
} else { | } else { | ||||
// If the user already has a linked account of this type, prevent them | |||||
// from linking a second account. This can happen if they swap logins | |||||
// and then refresh the account link. See T6707. We will eventually | |||||
// allow this after T2549. | |||||
$existing_accounts = id(new PhabricatorExternalAccountQuery()) | |||||
->setViewer($viewer) | |||||
->withUserPHIDs(array($viewer->getPHID())) | |||||
->withAccountTypes(array($account->getAccountType())) | |||||
->execute(); | |||||
if ($existing_accounts) { | |||||
return $this->renderError( | |||||
pht( | |||||
'Your Phabricator account is already connected to an external '. | |||||
'account on this provider ("%s"), but you are currently logged '. | |||||
'in to the provider with a different account. Log out of the '. | |||||
'external service, then log back in with the correct account '. | |||||
'before refreshing the account link.', | |||||
$provider->getProviderName())); | |||||
} | |||||
if ($provider->shouldAllowAccountLink()) { | if ($provider->shouldAllowAccountLink()) { | ||||
return $this->processLinkUser($account); | return $this->processLinkUser($account); | ||||
} else { | } else { | ||||
return $this->renderError( | return $this->renderError( | ||||
pht( | pht( | ||||
'The external account ("%s") you just authenticated with is '. | 'The external account ("%s") you just authenticated with is '. | ||||
'not configured to allow account linking on this Phabricator '. | 'not configured to allow account linking on this Phabricator '. | ||||
'install. An administrator may have recently disabled it.', | 'install. An administrator may have recently disabled it.', | ||||
▲ Show 20 Lines • Show All 127 Lines • Show Last 20 Lines |