diff --git a/app/Ninja/OAuth/OAuth.php b/app/Ninja/OAuth/OAuth.php index 487cd6172f..ae394775d9 100644 --- a/app/Ninja/OAuth/OAuth.php +++ b/app/Ninja/OAuth/OAuth.php @@ -30,7 +30,7 @@ class OAuth { $user = null; if($this->providerInstance) - $user = User::where('email', $this->providerInstance->getTokenResponse($token))->first(); + $user = User::where('oauth_user_id', $this->providerInstance->getTokenResponse($token))->first(); if ($user) return $user; diff --git a/app/Ninja/OAuth/Providers/Google.php b/app/Ninja/OAuth/Providers/Google.php index 0425b3f1d6..996ac8b8e4 100644 --- a/app/Ninja/OAuth/Providers/Google.php +++ b/app/Ninja/OAuth/Providers/Google.php @@ -9,7 +9,7 @@ class Google implements ProviderInterface $client = new \Google_Client(['client_id' => env('GOOGLE_CLIENT_ID','')]); $payload = $client->verifyIdToken($token); if ($payload) - return $this->harvestEmail($payload); + return $this->harvestSubField($payload); else return null; } @@ -19,5 +19,9 @@ class Google implements ProviderInterface return $payload['email']; } - + private function harvestSubField($payload) + { + $data = $payload->getAttributes(); + return $data['payload']['sub']; // user ID + } }