Skip to content

Commit b60daa8

Browse files
validation updates
1 parent 3104444 commit b60daa8

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/common/challenge-helper.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,11 @@ class ChallengeHelper {
117117
await ensureAcessibilityToModifiedGroups(currentUser, data, challenge);
118118
}
119119

120+
// Ensure descriptionFormat is either 'markdown' or 'html'
121+
if (data.descriptionFormat && !_.includes(["markdown", "html"], data.descriptionFormat)) {
122+
throw new errors.BadRequestError("The property 'descriptionFormat' must be either 'markdown' or 'html'");
123+
}
124+
120125
// Ensure unchangeable fields are not changed
121126
if (
122127
_.get(challenge, "legacy.track") &&

src/services/ChallengeService.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1515,6 +1515,13 @@ async function updateChallenge(currentUser, challengeId, data) {
15151515
_.set(data, "billing.markup", markup || 0);
15161516
}
15171517

1518+
// Make sure the user cannot change the direct project ID
1519+
if (data.legacy && data.legacy.directProjectId) {
1520+
const { directProjectId } = await projectHelper.getProject(projectId, currentUser);
1521+
1522+
_.set(challenge, "legacy.directProjectId", directProjectId);
1523+
}
1524+
15181525
/* BEGIN self-service stuffs */
15191526

15201527
// TODO: At some point in the future this should be moved to a Self-Service Challenge Helper

0 commit comments

Comments
 (0)