Skip to content

Smoke Testing 2020-11-05 : Auth0 hotfix #279

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- attach_workspace:
at: .
- run: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
- run: npm publish
- run: npm publish --tag test-release
# dont change anything
workflows:
version: 2
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"lint:js": "./node_modules/.bin/eslint --ext .js,.jsx .",
"test": "npm run lint && npm run jest"
},
"version": "1.1.0",
"version": "1000.25.1",
"dependencies": {
"auth0-js": "^6.8.4",
"config": "^3.2.0",
Expand Down
27 changes: 25 additions & 2 deletions src/actions/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,30 @@
import { createActions } from 'redux-actions';
import { decodeToken } from '@topcoder-platform/tc-auth-lib';
import { getApiV3, getApiV5 } from '../services/api';
import { setErrorIcon, ERROR_ICON_TYPES } from '../utils/errors';

/**
* Helper method that checks for HTTP error response v5 and throws Error in this case.
* @param {Object} res HTTP response object
* @return {Object} API JSON response object
* @private
*/
async function checkErrorV5(res) {
if (!res.ok) {
if (res.status === 403) {
setErrorIcon(ERROR_ICON_TYPES.API, 'Auth0', res.statusText);
}
throw new Error(res.statusText);
}
const jsonRes = (await res.json());
if (jsonRes.message) {
throw new Error(res.message);
}
return {
result: jsonRes,
headers: res.headers,
};
}

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

Expand Down