From 0517ebfb4e8e20ab309f9be9782a03f593300a66 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Fri, 17 Jan 2025 16:19:14 +0000 Subject: [PATCH] fix: auth user --- app/controllers/api/account.php | 11 +---------- src/Appwrite/Auth/OAuth2/Slack.php | 16 ++-------------- 2 files changed, 3 insertions(+), 24 deletions(-) diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index 74b9bc1868..6935029450 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -1346,16 +1346,7 @@ App::get('/v1/account/sessions/oauth2/:provider/redirect') ); } - $oauth2ID = ''; - try { - $oauth2ID = $oauth2->getUserID($accessToken); - } catch (Exception $ex) { - $failureRedirect( - $ex->getType(), - 'Failed to obtain user ID. The ' . $providerName . ' OAuth2 provider returned an error: ' . $ex->getMessage(), - ); - } - + $oauth2ID = $oauth2->getUserID($accessToken); if (empty($oauth2ID)) { $failureRedirect(Exception::USER_MISSING_ID); } diff --git a/src/Appwrite/Auth/OAuth2/Slack.php b/src/Appwrite/Auth/OAuth2/Slack.php index 1d6ba17a46..88d5b6a3a4 100644 --- a/src/Appwrite/Auth/OAuth2/Slack.php +++ b/src/Appwrite/Auth/OAuth2/Slack.php @@ -20,9 +20,7 @@ class Slack extends OAuth2 * @var array */ protected array $scopes = [ - 'openid', - 'email', - 'profile', + 'users:read', ]; /** @@ -63,13 +61,7 @@ class Slack extends OAuth2 'code' => $code, 'redirect_uri' => $this->callback ]) - ), true); - - if (!$this->tokens['ok']) { - throw new \Exception('Error in fetching access token: ' . $this->tokens['error']); - } - - $this->tokens['access_token'] = $this->tokens['authed_user']['access_token']; + ), true)['authed_user']; } return $this->tokens; @@ -174,10 +166,6 @@ class Slack extends OAuth2 ); $this->user = \json_decode($user, true); - - if (!$this->user['ok']) { - throw new \Exception('Error in fetching user: ' . $this->user['error']); - } } return $this->user;