Changeset View
Changeset View
Standalone View
Standalone View
src/applications/auth/adapter/PhutilGoogleAuthAdapter.php
| <?php | <?php | ||||
| /** | /** | ||||
| * Authentication adapter for Google OAuth2. | * Authentication adapter for Google OAuth2. | ||||
| */ | */ | ||||
| final class PhutilGoogleAuthAdapter extends PhutilOAuthAuthAdapter { | final class PhutilGoogleAuthAdapter extends PhutilOAuthAuthAdapter { | ||||
| public function getAdapterType() { | public function getAdapterType() { | ||||
| return 'google'; | return 'google'; | ||||
| } | } | ||||
| public function getAdapterDomain() { | public function getAdapterDomain() { | ||||
| return 'google.com'; | return 'google.com'; | ||||
| } | } | ||||
| public function getAccountID() { | protected function newAccountIdentifiers() { | ||||
| return $this->getAccountEmail(); | $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() { | public function getAccountEmail() { | ||||
| return $this->getOAuthAccountData('email'); | return $this->getOAuthAccountData('email'); | ||||
| } | } | ||||
| public function getAccountName() { | public function getAccountName() { | ||||
| // Guess account name from email address, this is just a hint anyway. | // Guess account name from email address, this is just a hint anyway. | ||||
| ▲ Show 20 Lines • Show All 80 Lines • Show Last 20 Lines | |||||