From f14a9afd996f0a85a8447a7561ff3f5a26f68d88 Mon Sep 17 00:00:00 2001 From: Tomo Norman Date: Wed, 27 Apr 2022 11:30:22 +0900 Subject: [PATCH] Fix Google Oauth Login --- src/Components/DfOAuthTwoProvider.php | 2 +- src/Components/GoogleProvider.php | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Components/DfOAuthTwoProvider.php b/src/Components/DfOAuthTwoProvider.php index a3a49d3..cd7b3fb 100644 --- a/src/Components/DfOAuthTwoProvider.php +++ b/src/Components/DfOAuthTwoProvider.php @@ -3,7 +3,7 @@ namespace DreamFactory\Core\OAuth\Components; use Illuminate\Support\Str; -use Symfony\Component\HttpFoundation\RedirectResponse; +use Illuminate\Http\RedirectResponse; use Laravel\Socialite\Two\InvalidStateException; use SocialiteProviders\Manager\OAuth2\User; diff --git a/src/Components/GoogleProvider.php b/src/Components/GoogleProvider.php index 6a9e32d..5969e7b 100644 --- a/src/Components/GoogleProvider.php +++ b/src/Components/GoogleProvider.php @@ -30,12 +30,15 @@ public function __construct($clientId, $clientSecret, $redirectUrl) */ protected function mapUserToObject(array $user) { + $avatarUrl = array_get($user, 'picture'); + return (new User)->setRaw($user)->map([ - 'id' => $user['id'], + 'id' => array_get($user, 'id'), 'nickname' => array_get($user, 'nickname'), - 'name' => $user['displayName'], - 'email' => $user['emails'][0]['value'], - 'avatar' => array_get($user, 'image')['url'], + 'name' => array_get($user, 'name'), + 'email' => array_get($user, 'email'), + 'avatar' => $avatarUrl, + 'avatar_original' => preg_replace('/\?sz=([0-9]+)/', '', $avatarUrl), ]); } } \ No newline at end of file