From 237b01637848ea93875fa0453232b408c1633060 Mon Sep 17 00:00:00 2001 From: Max Date: Thu, 18 Mar 2021 14:59:24 +0100 Subject: [PATCH] fix(provider): reject access token if slack login flow was canceled (#1544) * fix: reject access token if slack login flow was canceled * style: fix lint errors in oauth client --- src/server/lib/oauth/client.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/server/lib/oauth/client.js b/src/server/lib/oauth/client.js index 5c3e6a0d54..7ef9ae3863 100644 --- a/src/server/lib/oauth/client.js +++ b/src/server/lib/oauth/client.js @@ -167,9 +167,17 @@ async function getOAuth2AccessToken (code, provider, codeVerifier) { raw = querystring.parse(data) } - const accessToken = provider.id === 'slack' - ? raw.authed_user.access_token - : raw.access_token + let accessToken + if (provider.id === 'slack') { + const { ok, error } = raw + if (!ok) { + return reject(error) + } + + accessToken = raw.authed_user.access_token + } else { + accessToken = raw.access_token + } resolve({ accessToken,