From b7722790c5680c1a70bd09af39d6fdf91894d488 Mon Sep 17 00:00:00 2001 From: Andreas Kohn Date: Mon, 1 Feb 2016 11:28:27 +0100 Subject: [PATCH] Treat any status other than 201 as error --- lib/octonode/auth.js | 6 +++--- src/octonode/auth.coffee | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/octonode/auth.js b/lib/octonode/auth.js index 8518678..f5ddf93 100644 --- a/lib/octonode/auth.js +++ b/lib/octonode/auth.js @@ -81,10 +81,10 @@ err = _error; callback(new Error('Unable to parse body')); } - if (res.statusCode === 401) { - return callback(new Error(body.message)); - } else { + if (res.statusCode === 201) { return callback(null, body.id, body.token); + } else { + return callback(new Error(body.message)); } } }); diff --git a/src/octonode/auth.coffee b/src/octonode/auth.coffee index 4d0b51a..c412c29 100644 --- a/src/octonode/auth.coffee +++ b/src/octonode/auth.coffee @@ -67,7 +67,7 @@ auth = module.exports = body = JSON.parse body catch err callback new Error('Unable to parse body') - if res.statusCode is 401 then callback(new Error(body.message)) else callback(null, body.id, body.token) + if res.statusCode is 201 then callback(null, body.id, body.token) else callback(new Error(body.message)) else if @mode == @modes.web if scopes instanceof Array uri = 'https://github.com/login/oauth/authorize'