From 3094a853b67cd630415ad6e375d938b33550052d Mon Sep 17 00:00:00 2001 From: David Tulloh Date: Fri, 23 Mar 2018 00:52:43 +1100 Subject: [PATCH] Fix #59, getToken succeeds when token not supplied Includes fix and test case --- src/client-oauth2.js | 2 +- test/token.js | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/client-oauth2.js b/src/client-oauth2.js index 01aaa90..26843dd 100644 --- a/src/client-oauth2.js +++ b/src/client-oauth2.js @@ -469,7 +469,7 @@ TokenFlow.prototype.getToken = function (uri, opts) { // If no query string or fragment exists, we won't be able to parse // any useful information from the uri. - if (!url.hash && !url.query) { + if (!url.hash && !url.search) { return Promise.reject(new TypeError('Unable to process uri: ' + uri)) } diff --git a/test/token.js b/test/token.js index 90e3e98..d3cdf7d 100644 --- a/test/token.js +++ b/test/token.js @@ -47,5 +47,14 @@ describe('token', function () { }) }) }) + + it('should fail if token not present', function (done) { + githubAuth.token.getToken(config.redirectUri) + .then(function (ignore) { + done(new Error('Promise should fail')) + }, function (reason) { + done() // Promise is rejected - pass + }) + }) }) })