Skip to content

Commit 4ba7b6c

Browse files
authored
Merge pull request #450 from topcoder-platform/justin_client_manager_fix
Temp fix for client manager role assigned to self-service challenge c…
2 parents 4757f0c + a2af9fb commit 4ba7b6c

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

config/default.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ module.exports = {
6565

6666
MANAGER_ROLE_ID: process.env.MANAGER_ROLE_ID || '0e9c6879-39e4-4eb6-b8df-92407890faf1',
6767
OBSERVER_ROLE_ID: process.env.OBSERVER_ROLE_ID || '2a4dc376-a31c-4d00-b173-13934d89e286',
68+
CLIENT_MANAGER_ROLE_ID: process.env.OBSERVER_ROLE_ID || '9b2f1905-8128-42da-85df-ed64410f4781',
6869

6970
// health check timeout in milliseconds
7071
HEALTH_CHECK_TIMEOUT: process.env.HEALTH_CHECK_TIMEOUT || 3000,

src/services/ChallengeService.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,12 +1077,21 @@ async function createChallenge (currentUser, challenge, userToken) {
10771077
body: ret
10781078
})
10791079

1080-
// if created by a user, add user as a manager
1081-
if (currentUser.handle) {
1082-
// logger.debug(`Adding user as manager ${currentUser.handle}`)
1083-
await helper.createResource(ret.id, ret.createdBy, config.MANAGER_ROLE_ID)
1084-
} else {
1085-
// logger.debug(`Not adding manager ${currentUser.sub} ${JSON.stringify(currentUser)}`)
1080+
//If the challenge is self-service, add the creating user as the "client manager", *not* the manager
1081+
//This is necessary for proper handling of the vanilla embed on the self-service work item dashboard
1082+
if(challenge.legacy.selfService) {
1083+
if (currentUser.handle) {
1084+
await helper.createResource(ret.id, ret.createdBy, config.CLIENT_MANAGER_ROLE_ID)
1085+
}
1086+
}
1087+
else{
1088+
// if created by a user, add user as a manager, but only if *not* a self-service challenge
1089+
if (currentUser.handle) {
1090+
// logger.debug(`Adding user as manager ${currentUser.handle}`)
1091+
await helper.createResource(ret.id, ret.createdBy, config.MANAGER_ROLE_ID)
1092+
} else {
1093+
// logger.debug(`Not adding manager ${currentUser.sub} ${JSON.stringify(currentUser)}`)
1094+
}
10861095
}
10871096

10881097
// post bus event

0 commit comments

Comments
 (0)