From 741361a25277d57148aad242d0fe97c9c62d7dac Mon Sep 17 00:00:00 2001 From: LieutenantRoger Date: Mon, 21 Mar 2022 23:51:50 +0800 Subject: [PATCH 1/2] resource role check --- src/common/helper.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/common/helper.js b/src/common/helper.js index 1ab119b3..0f8821f0 100755 --- a/src/common/helper.js +++ b/src/common/helper.js @@ -447,6 +447,18 @@ function * checkCreateAccess (authUser, subEntity) { const phases = challengeDetails.body.phases const winner = challengeDetails.body.winners + // Check if the User is assigned as the reviewer for the contest + const reviewers = _.filter(currUserRoles, { role: 'Reviewer' }) + if (reviewers.length !== 0) { + throw new errors.HttpStatusError(400, `You cannot create a submission for a challenge while you are a reviewer`) + } + + // Check if the User is assigned as the iterative reviewer for the contest + const iterativeReviewers = _.filter(currUserRoles, { role: 'Iterative Reviewer' }) + if (iterativeReviewers.length !== 0) { + throw new errors.HttpStatusError(400, `You cannot create a submission for a challenge while you are a iterative reviewer`) + } + // Check if the User is registered for the contest const submitters = _.filter(currUserRoles, { role: 'Submitter' }) if (submitters.length === 0) { From 15973aed17b5b79533dea5d8dcec754da7e66c0a Mon Sep 17 00:00:00 2001 From: roger Date: Tue, 22 Mar 2022 12:44:07 +0800 Subject: [PATCH 2/2] adjust naming --- src/common/helper.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/helper.js b/src/common/helper.js index 0f8821f0..f050634c 100755 --- a/src/common/helper.js +++ b/src/common/helper.js @@ -456,7 +456,7 @@ function * checkCreateAccess (authUser, subEntity) { // Check if the User is assigned as the iterative reviewer for the contest const iterativeReviewers = _.filter(currUserRoles, { role: 'Iterative Reviewer' }) if (iterativeReviewers.length !== 0) { - throw new errors.HttpStatusError(400, `You cannot create a submission for a challenge while you are a iterative reviewer`) + throw new errors.HttpStatusError(400, `You cannot create a submission for a challenge while you are an iterative reviewer`) } // Check if the User is registered for the contest