Skip to content

Commit 5c36237

Browse files
author
sachin-maheshwari
authored
Merge pull request #890 from topcoder-platform/develop
Master : new auth changes - 29 Oct 2020
2 parents 1b1db6b + e2745ed commit 5c36237

File tree

7 files changed

+12
-13
lines changed

7 files changed

+12
-13
lines changed

config/constants/development.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ const DOMAIN = 'topcoder-dev.com'
22
const DEV_API_HOSTNAME = `https://api.${DOMAIN}`
33

44
module.exports = {
5-
ACCOUNTS_APP_CONNECTOR_URL: `https://accounts.${DOMAIN}/connector.html`,
6-
ACCOUNTS_APP_LOGIN_URL: `https://accounts.${DOMAIN}/member`,
5+
ACCOUNTS_APP_CONNECTOR_URL: `https://accounts-auth0.${DOMAIN}`,
6+
ACCOUNTS_APP_LOGIN_URL: `https://accounts-auth0.${DOMAIN}`,
77
COMMUNITY_APP_URL: `https://www.${DOMAIN}`,
88
MEMBER_API_URL: `${DEV_API_HOSTNAME}/v4/members`,
99
MEMBER_API_V3_URL: `${DEV_API_HOSTNAME}/v3/members`,
@@ -24,7 +24,7 @@ module.exports = {
2424
CONNECT_APP_URL: `https://connect.${DOMAIN}`,
2525
DIRECT_PROJECT_URL: `https://www.${DOMAIN}/direct`,
2626
ONLINE_REVIEW_URL: `https://software.${DOMAIN}`,
27-
DEFAULT_TERM_UUID: 'b11da5cd-713f-478d-90f4-f679ef53ee95', // Terms & Conditions of Use at TopCoder
27+
DEFAULT_TERM_UUID: '64d6e249-d7a5-4591-8ff5-e872f8a051f9', // Terms & Conditions of Use at TopCoder
2828
DEFAULT_NDA_UUID: '77f558c1-56fb-427c-b974-61ea0a060ca7', // Appirio NDA v2.0
2929
SUBMITTER_ROLE_UUID: '732339e7-8e30-49d7-9198-cccf9451e221',
3030
DEV_TRACK_ID: '9b6fc876-f4d9-4ccb-9dfd-419247628825',

config/constants/production.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ const DOMAIN = 'topcoder.com'
22
const PROD_API_HOSTNAME = `https://api.${DOMAIN}`
33

44
module.exports = {
5-
ACCOUNTS_APP_CONNECTOR_URL: process.env.ACCOUNTS_APP_CONNECTOR_URL || `https://accounts.${DOMAIN}/connector.html`,
6-
ACCOUNTS_APP_LOGIN_URL: `https://accounts.${DOMAIN}/member`,
5+
ACCOUNTS_APP_CONNECTOR_URL: process.env.ACCOUNTS_APP_CONNECTOR_URL || `https://accounts-auth0.${DOMAIN}`,
6+
ACCOUNTS_APP_LOGIN_URL: `https://accounts-auth0.${DOMAIN}`,
77
COMMUNITY_APP_URL: `https://www.${DOMAIN}`,
88
MEMBER_API_URL: `${PROD_API_HOSTNAME}/v4/members`,
99
MEMBER_API_V3_URL: `${PROD_API_HOSTNAME}/v3/members`,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
"sass-loader": "7.1.0",
9090
"simplemde": "^1.11.2",
9191
"style-loader": "0.23.0",
92-
"tc-accounts": "git+https://github.com/appirio-tech/accounts-app.git",
92+
"tc-auth-lib": "topcoder-platform/tc-auth-lib#1.0.1",
9393
"terser": "^3.16.1",
9494
"terser-webpack-plugin": "1.1.0",
9595
"topcoder-healthcheck-dropin": "^1.0.3",

src/actions/auth.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { configureConnector, decodeToken } from 'tc-accounts'
1+
import { configureConnector, decodeToken } from 'tc-auth-lib'
22
import { fetchProfile } from '../services/user'
33
import {
44
LOAD_USER_SUCCESS,

src/routes.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@
44
import React from 'react'
55
import PropTypes from 'prop-types'
66
import { Redirect, Route, Switch, withRouter } from 'react-router-dom'
7-
import jwtDecode from 'jwt-decode'
87
import _ from 'lodash'
98
import renderApp from './components/App'
109
import TopBarContainer from './containers/TopbarContainer'
1110
import Sidebar from './containers/Sidebar'
1211
import ChallengeList from './containers/Challenges'
1312
import ChallengeEditor from './containers/ChallengeEditor'
14-
import { getFreshToken } from 'tc-accounts'
13+
import { getFreshToken, decodeToken } from 'tc-auth-lib'
1514
import { saveToken } from './actions/auth'
1615
import { loadChallengeDetails } from './actions/challenges'
1716
import { connect } from 'react-redux'
@@ -78,7 +77,7 @@ class Routes extends React.Component {
7877
return null
7978
}
8079

81-
let isAllowed = checkAllowedRoles(_.get(jwtDecode(this.props.token), 'roles'))
80+
let isAllowed = checkAllowedRoles(_.get(decodeToken(this.props.token), 'roles'))
8281

8382
if (!isAllowed) {
8483
let warnMessage = 'You are not authorized to use this application'

src/services/axiosWithAuth.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import axios from 'axios'
22
import store from '../config/store'
3-
import { getFreshToken, isTokenExpired } from 'tc-accounts'
3+
import { getFreshToken, isTokenExpired } from 'tc-auth-lib'
44
const { ACCOUNTS_APP_LOGIN_URL } = process.env
55

66
/**

src/util/tc.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44
import { MARATHON_MATCH_SUBTRACKS, CHALLENGE_TRACKS, ALLOWED_USER_ROLES, ADMIN_ROLES } from '../config/constants'
55
import _ from 'lodash'
6-
import jwtDecode from 'jwt-decode'
6+
import { decodeToken } from 'tc-auth-lib'
77

88
export const RATING_COLORS = [{
99
color: '#9D9FA0' /* Grey */,
@@ -56,6 +56,6 @@ export const checkAllowedRoles = (roles) => roles.some(val => ALLOWED_USER_ROLES
5656
* @param token
5757
*/
5858
export const checkAdmin = (token) => {
59-
const roles = _.get(jwtDecode(token), 'roles')
59+
const roles = _.get(decodeToken(token), 'roles')
6060
return roles.some(val => ADMIN_ROLES.indexOf(val.toLowerCase()) > -1)
6161
}

0 commit comments

Comments
 (0)