Skip to content

Commit 0c11b79

Browse files
authored
Merge pull request #107 from topcoder-platform/dev
[PROD] fix: use u-bahn token for all u-bahn calls
2 parents 27f04a5 + be2f50f commit 0c11b79

File tree

1 file changed

+5
-28
lines changed

1 file changed

+5
-28
lines changed

src/common/helper.js

+5-28
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ function encodeQueryString (queryObj, nesting = '') {
245245
* @returns {String} user id.
246246
*/
247247
async function getUserIds (userId) {
248-
const token = await getM2MToken()
248+
const token = await getM2MUbahnToken()
249249
const q = {
250250
enrich: true,
251251
externalProfile: {
@@ -369,7 +369,7 @@ async function getTopcoderUserById (userId) {
369369
* @returns the request result
370370
*/
371371
async function getUserById (userId, enrich) {
372-
const token = await getM2MToken()
372+
const token = await getM2MUbahnToken()
373373
const res = await request
374374
.get(`${config.TC_API}/users/${userId}` + (enrich ? '?enrich=true' : ''))
375375
.set('Authorization', `Bearer ${token}`)
@@ -482,7 +482,7 @@ async function getProjectById (currentUser, id) {
482482
* @returns the request result
483483
*/
484484
async function getTopcoderSkills (criteria) {
485-
const token = await getM2MToken()
485+
const token = await getM2MUbahnToken()
486486
try {
487487
const res = await request
488488
.get(`${config.TC_API}/skills`)
@@ -514,7 +514,7 @@ async function getTopcoderSkills (criteria) {
514514
* @returns the request result
515515
*/
516516
async function getSkillById (skillId) {
517-
const token = await getM2MToken()
517+
const token = await getM2MUbahnToken()
518518
const res = await request
519519
.get(`${config.TC_API}/skills/${skillId}`)
520520
.set('Authorization', `Bearer ${token}`)
@@ -524,28 +524,6 @@ async function getSkillById (skillId) {
524524
return _.pick(res.body, ['id', 'name'])
525525
}
526526

527-
/**
528-
* Function to get user skills
529-
* @param {String} token the user request token
530-
* @param {String} userId user id
531-
* @returns the request result
532-
*/
533-
async function getUserSkill (token, userId) {
534-
const url = `${config.TC_API}/users/${userId}/skills`
535-
const res = await request
536-
.get(url)
537-
.set('Authorization', token)
538-
.set('Content-Type', 'application/json')
539-
.set('Accept', 'application/json')
540-
localLogger.debug({ context: 'getUserSkill', message: `response body: ${JSON.stringify(res.body)}` })
541-
return _.map(res.body, item => {
542-
return {
543-
id: item.id,
544-
name: item.skill.name
545-
}
546-
})
547-
}
548-
549527
/**
550528
* Encapsulate the getUserId function.
551529
* Make sure a user exists in ubahn(/v5/users) and return the id of the user.
@@ -587,7 +565,7 @@ async function ensureJobById (jobId) {
587565
* @returns {Object} the user data
588566
*/
589567
async function ensureUserById (userId) {
590-
const token = await getM2MToken()
568+
const token = await getM2MUbahnToken()
591569
try {
592570
const res = await request
593571
.get(`${config.TC_API}/users/${userId}`)
@@ -660,7 +638,6 @@ module.exports = {
660638
getProjectById,
661639
getTopcoderSkills,
662640
getSkillById,
663-
getUserSkill,
664641
ensureJobById,
665642
ensureUserById,
666643
getAuditM2Muser,

0 commit comments

Comments
 (0)