Skip to content
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.

Commit

Permalink
Fix #59, getToken succeeds when token not supplied
Browse files Browse the repository at this point in the history
Includes fix and test case
  • Loading branch information
lod committed Mar 22, 2018
1 parent 30fe581 commit 3094a85
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/client-oauth2.js
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}

Expand Down
9 changes: 9 additions & 0 deletions test/token.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
})
})
})

0 comments on commit 3094a85

Please sign in to comment.