Skip to content

Commit 7fa2075

Browse files
Only allow m2m to modify task information on challenges
1 parent 863ff04 commit 7fa2075

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/services/ChallengeService.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1452,6 +1452,15 @@ async function update (currentUser, challengeId, data, userToken, isFull) {
14521452

14531453
const { track, type } = await validateChallengeData(_.pick(challenge, ['trackId', 'typeId']))
14541454

1455+
// Only m2m tokens are allowed to modify the `task.*` information on a challenge
1456+
if (!_.isUndefined(_.get(data, 'task')) && !currentUser.isMachine) {
1457+
if (!_.isUndefined(_.get(challenge, 'task'))) {
1458+
data.task = challenge.task
1459+
} else {
1460+
delete data.task
1461+
}
1462+
}
1463+
14551464
if (_.get(type, 'isTask')) {
14561465
if (!_.isEmpty(_.get(data, 'task.memberId'))) {
14571466
const challengeResources = await helper.getChallengeResources(challengeId)

0 commit comments

Comments
 (0)