Skip to content

Prevent adding more than one submitter on a challenge.task.isTask = true #37

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
Aug 1, 2020
Merged
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
8 changes: 8 additions & 0 deletions src/services/ResourceService.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,14 @@ async function init (currentUser, challengeId, resource, isCreated) {
const challengeRes = await helper.getRequest(`${config.CHALLENGE_API_URL}/${challengeId}`)
const challenge = challengeRes.body

// Prevent from creating more than 1 submitter resources on tasks
if (_.get(challenge, 'task.isTask', false) && isCreated && resource.roleId === config.SUBMITTER_RESOURCE_ROLE_ID) {
const existing = await getResources(currentUser, challengeId, config.SUBMITTER_RESOURCE_ROLE_ID, 1, 1)
if (existing.total > 0) {
throw new errors.ConflictError(`The Task is already assigned`)
}
}

// logger.error(`Init Member for ${JSON.stringify(currentUser)}`)
// get member information using v3 API
const handle = resource.memberHandle
Expand Down