Skip to content

Commit

Permalink
fix(provider): reject access token if slack login flow was canceled (n…
Browse files Browse the repository at this point in the history
…extauthjs#1544)

* fix: reject access token if slack login flow was canceled

* style: fix lint errors in oauth client
  • Loading branch information
mrmurb authored Mar 18, 2021
1 parent 776b948 commit 237b016
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/server/lib/oauth/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 237b016

Please sign in to comment.