Skip to content

Commit 67959c3

Browse files
authored
More error checking (#1802)
* Transform GH 401 to 503 . Mentioned at https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/ and encountered with newer *(attempted)* migrated dep. * Spec for authorization shows uppercasing... so new dep has it with incorrect casing I believe... may not matter on their server but consistancy here. Reverting. * Add a few more important comments Applies to #1705 #37 and post #1799 Ref(s): * https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.8 * https://developer.mozilla.org/docs/Web/HTTP/Authentication Auto-merge
1 parent c0cdd54 commit 67959c3

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

controllers/user.js

+9-3
Original file line numberDiff line numberDiff line change
@@ -1254,7 +1254,9 @@ exports.userGitHubRepoListPage = function (aReq, aRes, aNext) {
12541254
var msg = null;
12551255

12561256
if (aErr) {
1257-
switch (aErr.code) {
1257+
switch (aErr.code) { // NOTE: Important to test for GH code vs potential OUJS code
1258+
case 401:
1259+
// fallsthrough
12581260
case 403:
12591261
try {
12601262
msg = JSON.parse(aErr.message);
@@ -1398,7 +1400,9 @@ exports.userGitHubRepoPage = function (aReq, aRes, aNext) {
13981400
var msg = null;
13991401

14001402
if (aErr) {
1401-
switch (aErr.code) {
1403+
switch (aErr.code) { // NOTE: Important to test for GH code vs potential OUJS code
1404+
case 401:
1405+
// fallsthrough
14021406
case 403:
14031407
try {
14041408
msg = JSON.parse(aErr.message);
@@ -1766,7 +1770,9 @@ exports.userGitHubImportScriptPage = function (aReq, aRes, aNext) {
17661770
}
17671771

17681772
if (!(aErr instanceof String)) {
1769-
switch (aErr.code) { // NOTE: Important to test for GH 403 vs potential OUJS 403
1773+
switch (aErr.code) { // NOTE: Important to test for GH code vs potential OUJS code
1774+
case 401:
1775+
// fallsthrough
17701776
case 403:
17711777
try {
17721778
msg = JSON.parse(aErr.message);

libs/repoManager.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ function fetchJSON(aPath, aCallback) {
107107
encodedAuth = Buffer.from(`${clientId}:${clientKey}`).toString('base64');
108108
opts = {
109109
headers: {
110-
authorization: `basic ${encodedAuth}`
110+
Authorization: `Basic ${encodedAuth}`
111111
}
112112
};
113113
}

0 commit comments

Comments
 (0)