Skip to content

Commit c593017

Browse files
Merge pull request #279 from topcoder-platform/auth0-hotfix-v3
Smoke Testing 2020-11-05 : Auth0 hotfix
2 parents 8f9a0f8 + 595ff22 commit c593017

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

.circleci/config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
- attach_workspace:
2929
at: .
3030
- run: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
31-
- run: npm publish
31+
- run: npm publish --tag test-release
3232
# dont change anything
3333
workflows:
3434
version: 2

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"lint:js": "./node_modules/.bin/eslint --ext .js,.jsx .",
3232
"test": "npm run lint && npm run jest"
3333
},
34-
"version": "1.1.0",
34+
"version": "1000.25.1",
3535
"dependencies": {
3636
"auth0-js": "^6.8.4",
3737
"config": "^3.2.0",

src/actions/auth.js

+25-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,30 @@
66
import { createActions } from 'redux-actions';
77
import { decodeToken } from '@topcoder-platform/tc-auth-lib';
88
import { getApiV3, getApiV5 } from '../services/api';
9+
import { setErrorIcon, ERROR_ICON_TYPES } from '../utils/errors';
10+
11+
/**
12+
* Helper method that checks for HTTP error response v5 and throws Error in this case.
13+
* @param {Object} res HTTP response object
14+
* @return {Object} API JSON response object
15+
* @private
16+
*/
17+
async function checkErrorV5(res) {
18+
if (!res.ok) {
19+
if (res.status === 403) {
20+
setErrorIcon(ERROR_ICON_TYPES.API, 'Auth0', res.statusText);
21+
}
22+
throw new Error(res.statusText);
23+
}
24+
const jsonRes = (await res.json());
25+
if (jsonRes.message) {
26+
throw new Error(res.message);
27+
}
28+
return {
29+
result: jsonRes,
30+
headers: res.headers,
31+
};
32+
}
933

1034
/**
1135
* @static
@@ -22,8 +46,7 @@ function loadProfileDone(userTokenV3) {
2246
apiV3.get(`/members/${user.handle}`)
2347
.then(res => res.json()).then(res => (res.result.status === 200 ? res.result.content : {})),
2448
apiV5.get(`/groups?memberId=${user.userId}&membershipType=user`)
25-
.then(res => (res.ok ? res.json() : new Error(res.statusText)))
26-
.then(res => (res.message ? new Error(res.message) : res)),
49+
.then(checkErrorV5).then(res => res.result || []),
2750
]).then(([profile, groups]) => ({ ...profile, groups }));
2851
}
2952

0 commit comments

Comments
 (0)