Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 299413e

Browse files
author
Sachin Maheshwari
committed
directly reading handle from token instead calling v2 user profile api
1 parent ffa89bb commit 299413e

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/config.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,10 @@ const frontendConfigs = {
109109
"JWT_V2_NAME":"tcjwt",
110110
"COOKIES_SECURE":false,
111111
"TC_LOGIN_URL": "https://accounts.topcoder-dev.com/member",
112+
113+
// TODO: we can clean this conf, as no need https://github.com/topcoder-platform/topcoder-x-ui/issues/342
112114
"TC_USER_PROFILE_URL": "https://api.topcoder-dev.com/v2/user/profile",
115+
113116
"API_URL": "https://api.topcoder-dev.com",
114117
"ADMIN_TOOL_URL": "https://api.topcoder-dev.com/v2",
115118
"ACCOUNTS_CONNECTOR_URL": "https://accounts.topcoder-dev.com/connector.html",
@@ -173,4 +176,4 @@ module.exports.frontendConfigs = {
173176
TOPCODER_URL: process.env.TOPCODER_URL || frontendConfigs[activeEnv].TOPCODER_URL,
174177
GITHUB_TEAM_URL: process.env.GITHUB_TEAM_URL || frontendConfigs[activeEnv].GITHUB_TEAM_URL,
175178
GITLAB_GROUP_URL: process.env.GITLAB_GROUP_URL || frontendConfigs[activeEnv].GITLAB_GROUP_URL
176-
};
179+
};

src/services/TCUserService.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const config = require('../config');
1515
const errors = require('../common/errors');
1616
const helper = require('../common/helper');
1717
const UserMapping = require('../models').UserMapping;
18+
const decodeToken = require('@topcoder-platform/tc-auth-lib').decodeToken;
1819

1920
const request = superagentPromise(superagent, Promise);
2021

@@ -25,13 +26,16 @@ const request = superagentPromise(superagent, Promise);
2526
* @returns {String} the handle
2627
*/
2728
async function getHandle(token) {
28-
const handle = await request
29+
//issue - https://github.com/topcoder-platform/topcoder-x-ui/issues/342
30+
31+
/* const handle = await request
2932
.get(config.TOPCODER_VALUES[config.TOPCODER_ENV].TC_USER_PROFILE_URL)
3033
.set('Authorization', `Bearer ${token}`)
3134
.end()
3235
.then((res) => res.body.handle);
33-
34-
return handle;
36+
*/
37+
const decoded = decodeToken(token);
38+
return decoded.handle;
3539
}
3640

3741
getHandle.schema = Joi.object().keys({

0 commit comments

Comments
 (0)