From 83a9409f8b4fa4983929120636a48f68a01c4f38 Mon Sep 17 00:00:00 2001 From: Ben Date: Thu, 23 Sep 2021 22:23:02 +0800 Subject: [PATCH 1/2] Include a check to ensure accessToken is return --- lib/strategy.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/strategy.js b/lib/strategy.js index 07b87f1..8a7f691 100644 --- a/lib/strategy.js +++ b/lib/strategy.js @@ -175,6 +175,7 @@ OAuth2Strategy.prototype.authenticate = function(req, options) { self._oauth2.getOAuthAccessToken(code, params, function(err, accessToken, refreshToken, params) { if (err) { return self.error(self._createOAuthError('Failed to obtain access token', err)); } + if (!accessToken){ return self._createOAuthError('Failed to obtain access token', err)} self._loadUserProfile(accessToken, function(err, profile) { if (err) { return self.error(err); } From ec7298324799f879a40b9a2a58bcb4be704c37de Mon Sep 17 00:00:00 2001 From: Ben Date: Thu, 23 Sep 2021 22:24:46 +0800 Subject: [PATCH 2/2] Include a check to ensure accessToken is returned --- lib/strategy.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/strategy.js b/lib/strategy.js index 8a7f691..60ad54a 100644 --- a/lib/strategy.js +++ b/lib/strategy.js @@ -174,8 +174,7 @@ OAuth2Strategy.prototype.authenticate = function(req, options) { self._oauth2.getOAuthAccessToken(code, params, function(err, accessToken, refreshToken, params) { - if (err) { return self.error(self._createOAuthError('Failed to obtain access token', err)); } - if (!accessToken){ return self._createOAuthError('Failed to obtain access token', err)} + if (err || !accessToken) { return self.error(self._createOAuthError('Failed to obtain access token', err)); } self._loadUserProfile(accessToken, function(err, profile) { if (err) { return self.error(err); }