From d3c1e2e7ab7165722aa70c57830841a15454bb77 Mon Sep 17 00:00:00 2001 From: "Luiz R. Rodrigues" Date: Wed, 4 Nov 2020 07:29:31 -0300 Subject: [PATCH 1/6] Auth - Added API V5 response --- src/actions/auth.js | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/actions/auth.js b/src/actions/auth.js index f81b62f9..d65f0cfe 100644 --- a/src/actions/auth.js +++ b/src/actions/auth.js @@ -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 @@ -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 })); } From c818f2090189b22a56a885cb4b6902a03f950df8 Mon Sep 17 00:00:00 2001 From: "Luiz R. Rodrigues" Date: Wed, 4 Nov 2020 07:35:10 -0300 Subject: [PATCH 2/6] Auth0 hotfix --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8435779d..578a2041 100644 --- a/package.json +++ b/package.json @@ -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", From 595ff22b1b0d1cfc76b3bd31612c5cb6ae8d465a Mon Sep 17 00:00:00 2001 From: "Luiz R. Rodrigues" Date: Wed, 4 Nov 2020 07:35:26 -0300 Subject: [PATCH 3/6] ci: added dist tag --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 0e161844..e8eac28e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -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 From 09291f1907705d1a36ef7a801894f28e1dc6746b Mon Sep 17 00:00:00 2001 From: Luiz Ricardo Rodrigues Date: Wed, 4 Nov 2020 18:42:12 -0300 Subject: [PATCH 4/6] Smoke Testing 2020-11-04 : Auth0 hotfix Issue: https://github.com/topcoder-platform/community-app/issues/5159 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 578a2041..e63096ac 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "lint:js": "./node_modules/.bin/eslint --ext .js,.jsx .", "test": "npm run lint && npm run jest" }, - "version": "1000.25.1", + "version": "1000.25.2", "dependencies": { "auth0-js": "^6.8.4", "config": "^3.2.0", From c61b692bab4fcc0a31bf61f6dda79885764ee058 Mon Sep 17 00:00:00 2001 From: Luiz Ricardo Rodrigues Date: Thu, 5 Nov 2020 07:41:22 -0300 Subject: [PATCH 5/6] ci: remove dist tag --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e8eac28e..0e161844 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -28,7 +28,7 @@ jobs: - attach_workspace: at: . - run: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc - - run: npm publish --tag test-release + - run: npm publish # dont change anything workflows: version: 2 From 8109cb261242f364dfe69bb0bcff5ee3c63a6006 Mon Sep 17 00:00:00 2001 From: Luiz Ricardo Rodrigues Date: Thu, 5 Nov 2020 07:43:37 -0300 Subject: [PATCH 6/6] fix: for issue #5159 Issue: https://github.com/topcoder-platform/community-app/issues/5159 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e63096ac..6c0a4e59 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "lint:js": "./node_modules/.bin/eslint --ext .js,.jsx .", "test": "npm run lint && npm run jest" }, - "version": "1000.25.2", + "version": "1.1.1", "dependencies": { "auth0-js": "^6.8.4", "config": "^3.2.0",