mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 00:42:41 +01:00
Read both email addresses and Google Account IDs from Google OAuth
Summary: Ref T13493. Google returns a lower-quality account identifier ("email") and a higher-quality account identifier ("id"). We currently read only "email". Change the logic to read both "email" and "id", so that if Google ever moves away from "email" the transition will be a bit easier. Test Plan: Linked/unlinked a Google account, looked at the external account identifier table. Maniphest Tasks: T13493 Differential Revision: https://secure.phabricator.com/D21028
This commit is contained in:
parent
785f3c98da
commit
d0f4554dbe
2 changed files with 17 additions and 9 deletions
|
@ -13,8 +13,23 @@ final class PhutilGoogleAuthAdapter extends PhutilOAuthAuthAdapter {
|
|||
return 'google.com';
|
||||
}
|
||||
|
||||
public function getAccountID() {
|
||||
return $this->getAccountEmail();
|
||||
protected function newAccountIdentifiers() {
|
||||
$identifiers = array();
|
||||
|
||||
$account_id = $this->getOAuthAccountData('id');
|
||||
if ($account_id !== null) {
|
||||
$account_id = sprintf(
|
||||
'id(%s)',
|
||||
$account_id);
|
||||
$identifiers[] = $this->newAccountIdentifier($account_id);
|
||||
}
|
||||
|
||||
$email = $this->getAccountEmail();
|
||||
if ($email !== null) {
|
||||
$identifiers[] = $this->newAccountIdentifier($email);
|
||||
}
|
||||
|
||||
return $identifiers;
|
||||
}
|
||||
|
||||
public function getAccountEmail() {
|
||||
|
|
|
@ -204,13 +204,6 @@ abstract class PhabricatorAuthProvider extends Phobject {
|
|||
get_class($this)));
|
||||
}
|
||||
|
||||
if (count($identifiers) !== 1) {
|
||||
throw new Exception(
|
||||
pht(
|
||||
'Unexpected number of account identifiers returned (by class "%s").',
|
||||
get_class($this)));
|
||||
}
|
||||
|
||||
$config = $this->getProviderConfig();
|
||||
$viewer = PhabricatorUser::getOmnipotentUser();
|
||||
|
||||
|
|
Loading…
Reference in a new issue