Skip to content

Commit ba4f33d

Browse files
committed
fixed
1 parent 84ae548 commit ba4f33d

File tree

2 files changed

+27
-7
lines changed

2 files changed

+27
-7
lines changed

api/controllers/Challenges.js

+19-7
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ const refreshCategoryMetaData = async () => {
150150
}
151151

152152
const listCategoryInfo = async (req, res) => {
153-
153+
154154
if (req.locals.perms < 1) throw new Error('Permissions');
155155
const newCategoryMeta = await refreshCategoryMetaData()
156156
res.send({
@@ -248,12 +248,24 @@ const show = async (req, res) => {
248248
if (chall.solves.find(element => element === req.locals.username) === undefined) chall.writeup = "CompleteFirst"
249249
}
250250
}
251-
if (chall.max_attempts != 0)
252-
chall.used_attempts = await collections.transactions.countDocuments({
253-
author: req.locals.username,
254-
challengeID: MongoDB.ObjectId(req.params.chall),
255-
type: 'submission'
256-
}, { limit: chall.max_attempts });
251+
if (chall.max_attempts != 0) {
252+
if (NodeCacheObj.get("teamMode") && req.locals.username in usernameTeamCache) {
253+
chall.used_attempts = await collections.transactions.countDocuments({
254+
originalAuthor: req.locals.username,
255+
challengeID: MongoDB.ObjectId(req.params.chall),
256+
type: 'submission'
257+
});
258+
}
259+
else {
260+
chall.used_attempts = await collections.transactions.countDocuments({
261+
author: req.locals.username,
262+
challengeID: MongoDB.ObjectId(req.params.chall),
263+
type: 'submission'
264+
});
265+
}
266+
}
267+
268+
257269
res.send({
258270
success: true,
259271
chall: chall

client/src/Challenges/challengesTagSort.js

+8
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,7 @@ class ChallengesTagSort extends React.Component {
474474
'It seems like you submitted an incorrect flag "' + values.flag + '" for "' + this.state.viewingChallengeDetails.name + '".',
475475
duration: 3
476476
});
477+
this.loadChallengeDetails(this.state.currentChallenge, false)
477478
}
478479
}
479480
else {
@@ -484,6 +485,7 @@ class ChallengesTagSort extends React.Component {
484485
'It seems like you have execeeded the maximum number of attempts for "' + this.state.viewingChallengeDetails.name + '". Contact an admin if you need more tries.',
485486
duration: 3
486487
});
488+
this.loadChallengeDetails(this.state.currentChallenge, false)
487489
}
488490
else if (data.error === "submitted") {
489491
notification["error"]({
@@ -492,6 +494,7 @@ class ChallengesTagSort extends React.Component {
492494
'Your teammate might have already solved the challenge. Please refresh the page to see the latest solve status.',
493495
duration: 3
494496
});
497+
await this.props.handleRefresh()
495498
}
496499
else if (data.error === "admin-hidden") {
497500
notification["error"]({
@@ -500,6 +503,7 @@ class ChallengesTagSort extends React.Component {
500503
'Submission has been disabled as this challenge is hidden even for admins. This is to prevent challenge leakages.',
501504
duration: 3
502505
});
506+
this.loadChallengeDetails(this.state.currentChallenge, false)
503507
}
504508
else if (data.error === "required-challenge-not-completed") {
505509
notification["error"]({
@@ -508,6 +512,7 @@ class ChallengesTagSort extends React.Component {
508512
'It seems like you have not completed the required challenge before doing this challenge.',
509513
duration: 3
510514
});
515+
this.loadChallengeDetails(this.state.currentChallenge, false)
511516
}
512517
else if (data.error === "required-challenge-not-found") {
513518
notification["error"]({
@@ -516,6 +521,7 @@ class ChallengesTagSort extends React.Component {
516521
'This is likely an error in the challenge settings. Please contact an admin.',
517522
duration: 3
518523
});
524+
this.loadChallengeDetails(this.state.currentChallenge, false)
519525
}
520526
else if (data.error === "submission-disabled") {
521527
notification["error"]({
@@ -524,6 +530,7 @@ class ChallengesTagSort extends React.Component {
524530
'New flag submissions have been disabled. The competition might have ended/is not running.',
525531
duration: 3
526532
});
533+
this.loadChallengeDetails(this.state.currentChallenge, false)
527534
}
528535
else if (data.error === "InvalidFlagLength") {
529536
notification["error"]({
@@ -532,6 +539,7 @@ class ChallengesTagSort extends React.Component {
532539
'Please do not spam the server with submissions that are too long.',
533540
duration: 3
534541
});
542+
this.loadChallengeDetails(this.state.currentChallenge, false)
535543
}
536544
else {
537545
console.log(data.error)

0 commit comments

Comments
 (0)