From 37ad61933cccee10d6130461d8b610b8c2932197 Mon Sep 17 00:00:00 2001 From: Steven Nguyen Date: Thu, 22 Jun 2023 17:46:09 -0700 Subject: [PATCH] Set email & name after OAuth if they're empty The logic before was incorrect. Really, email and name should only be set if they're empty. --- app/controllers/api/account.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index 49c5ef3376..16f6306a8f 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -566,13 +566,12 @@ App::get('/v1/account/sessions/oauth2/:provider/redirect') 'countryCode' => ($record) ? \strtolower($record['country']['iso_code']) : '--', ], $detector->getOS(), $detector->getClient(), $detector->getDevice())); - $isAnonymousUser = Auth::isAnonymousUser($user); + if (empty($user->getAttribute('email'))) { + $user->setAttribute('email', $oauth2->getUserEmail($accessToken)); + } - if ($isAnonymousUser) { - $user - ->setAttribute('name', $oauth2->getUserName($accessToken)) - ->setAttribute('email', $oauth2->getUserEmail($accessToken)) - ; + if (empty($user->getAttribute('name'))) { + $user->setAttribute('name', $oauth2->getUserName($accessToken)); } $user