Skip to content

Temp fix for client manager role assigned to self-service challenge c… #450

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ module.exports = {

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

// health check timeout in milliseconds
HEALTH_CHECK_TIMEOUT: process.env.HEALTH_CHECK_TIMEOUT || 3000,
Expand Down
21 changes: 15 additions & 6 deletions src/services/ChallengeService.js
Original file line number Diff line number Diff line change
Expand Up @@ -1077,12 +1077,21 @@ async function createChallenge (currentUser, challenge, userToken) {
body: ret
})

// if created by a user, add user as a manager
if (currentUser.handle) {
// logger.debug(`Adding user as manager ${currentUser.handle}`)
await helper.createResource(ret.id, ret.createdBy, config.MANAGER_ROLE_ID)
} else {
// logger.debug(`Not adding manager ${currentUser.sub} ${JSON.stringify(currentUser)}`)
//If the challenge is self-service, add the creating user as the "client manager", *not* the manager
//This is necessary for proper handling of the vanilla embed on the self-service work item dashboard
if(challenge.legacy.selfService) {
if (currentUser.handle) {
await helper.createResource(ret.id, ret.createdBy, config.CLIENT_MANAGER_ROLE_ID)
}
}
else{
// if created by a user, add user as a manager, but only if *not* a self-service challenge
if (currentUser.handle) {
// logger.debug(`Adding user as manager ${currentUser.handle}`)
await helper.createResource(ret.id, ret.createdBy, config.MANAGER_ROLE_ID)
} else {
// logger.debug(`Not adding manager ${currentUser.sub} ${JSON.stringify(currentUser)}`)
}
}

// post bus event
Expand Down