Skip to content

Commit d8c872d

Browse files
committed
returnError
1 parent c13cfa2 commit d8c872d

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "simple-oauth2-github",
3-
"version": "0.5.0",
3+
"version": "0.5.1",
44
"description": "A simple Node.js client library for GitHub OAuth2.",
55
"keywords": [
66
"oauth2",

src/index.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,15 @@ module.exports = {
9595
// Middleware to request access_token.
9696
const accessToken = (req, res, next) => {
9797
const code = req.query.code;
98+
9899
if (!code) {
99-
return next(new Error('SimpleOAuth2Github expects [code] param in the request'));
100+
const error = new Error('SimpleOAuth2Github expects [code] param in the request');
101+
102+
if (args.returnError) {
103+
req.tokenError = error;
104+
}
105+
106+
return next(args.returnError ? null : error);
100107
}
101108

102109
// Exchange code for access_token.

0 commit comments

Comments
 (0)