Skip to content

Commit 23f25b2

Browse files
Merge branch 'develop' into stats-history-v4
2 parents 1051c21 + 8109cb2 commit 23f25b2

File tree

13 files changed

+42
-19
lines changed

13 files changed

+42
-19
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
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 --tag test-release
31+
- run: npm publish
3232
# dont change anything
3333
workflows:
3434
version: 2

__tests__/reducers/auth.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const mockActions = {
2020
jest.setMock(require.resolve('actions/auth'), mockActions);
2121
jest.setMock(require.resolve('actions/profile'), mockActions);
2222

23-
jest.setMock('tc-accounts', {
23+
jest.setMock('@topcoder-platform/tc-auth-lib', {
2424
decodeToken: () => 'User object',
2525
isTokenExpired: () => false,
2626
});

__tests__/reducers/challenge.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const mockSmpActions = {
4444
};
4545
_.merge(actions, mockSmpActions);
4646

47-
jest.setMock('tc-accounts', {
47+
jest.setMock('@topcoder-platform/tc-auth-lib', {
4848
decodeToken: () => 'User object',
4949
isTokenExpired: () => false,
5050
});

config/jest/setup.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* global jest */
22
require('topcoder-react-utils/config/jest/setup');
33

4-
jest.setMock('tc-accounts', {
4+
jest.setMock('@topcoder-platform/tc-auth-lib', {
55
decodeToken: token => (token ? {
66
handle: 'username12345',
77
userId: '12345',

config/webpack/default.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ module.exports = {
2222
'redux',
2323
'redux-actions',
2424
'isomorphic-fetch',
25-
'tc-accounts',
25+
'@topcoder-platform/tc-auth-lib',
2626
'to-capital-case',
2727
'topcoder-react-utils',
2828
'tc-core-library-js',

package.json

Lines changed: 3 additions & 3 deletions
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": "1000.25.0",
34+
"version": "1000.25.7",
3535
"dependencies": {
3636
"auth0-js": "^6.8.4",
3737
"config": "^3.2.0",
@@ -47,10 +47,10 @@
4747
"react-redux": "^6.0.1",
4848
"redux": "^3.7.2",
4949
"redux-actions": "^2.4.0",
50-
"tc-accounts": "https://github.com/appirio-tech/accounts-app.git#dev",
5150
"tc-core-library-js": "appirio-tech/tc-core-library-js.git#v2.6",
5251
"to-capital-case": "^1.0.0",
53-
"topcoder-react-utils": "0.7.5"
52+
"topcoder-react-utils": "0.7.5",
53+
"@topcoder-platform/tc-auth-lib": "git+https://github.com/topcoder-platform/tc-auth-lib.git#1.0.1"
5454
},
5555
"devDependencies": {
5656
"autoprefixer": "^8.6.4",

src/actions/auth.js

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,32 @@
44
*/
55

66
import { createActions } from 'redux-actions';
7-
import { decodeToken } from 'tc-accounts';
7+
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

src/actions/challenge.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import _ from 'lodash';
88
import { config } from 'topcoder-react-utils';
99
import { createActions } from 'redux-actions';
10-
import { decodeToken } from 'tc-accounts';
10+
import { decodeToken } from '@topcoder-platform/tc-auth-lib';
1111
import { getService as getChallengesService } from '../services/challenges';
1212
import { getService as getSubmissionService } from '../services/submissions';
1313
import { getApi } from '../services/api';
@@ -248,7 +248,7 @@ function loadResultsInit(challengeId) {
248248
* @return {Action}
249249
*/
250250
function loadResultsDone(auth, challengeId, type) {
251-
return getApi('V2', auth.tokenV2)
251+
return getApi('V2')
252252
.fetch(`/${type}/challenges/result/${challengeId}`)
253253
.then(response => response.json())
254254
.then(response => ({
@@ -273,7 +273,7 @@ function fetchCheckpointsInit() {}
273273
*/
274274
function fetchCheckpointsDone(tokenV2, challengeId) {
275275
const endpoint = `/design/challenges/checkpoint/${challengeId}`;
276-
return getApi('V2', tokenV2).fetch(endpoint)
276+
return getApi('V2').fetch(endpoint)
277277
.then((response) => {
278278
if (response.status !== 200) {
279279
throw response.status;

src/reducers/auth.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*/
1414

1515
import _ from 'lodash';
16-
import { decodeToken } from 'tc-accounts';
16+
import { decodeToken } from '@topcoder-platform/tc-auth-lib';
1717
import { redux } from 'topcoder-react-utils';
1818
import actions from '../actions/auth';
1919
import profileActions from '../actions/profile';

src/reducers/challenge.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ function onFetchCheckpointsDone(state, action) {
173173
loadingCheckpoints: false,
174174
};
175175
}
176-
if (state.details && state.details.legacyId === action.payload.challengeId) {
176+
if (state.details && `${state.details.legacyId}` === `${action.payload.challengeId}`) {
177177
return {
178178
...state,
179179
checkpoints: action.payload.checkpoints,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy