Skip to content

Commit 37544f7

Browse files
authored
Remove async from CTFd.pages.challenge.checkSolution (#35)
* Remove async from `CTFd.pages.challenge.checkSolution` * Fix `solved` behavior in `CTFd.pages.challenge.checkSolution`
1 parent 561d8af commit 37544f7

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

pages/challenge.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ export async function getSolution(challengeId) {
143143
}
144144

145145
// Function to check whether the UI should check for a challenge solution
146-
export async function checkSolution(solutionState, challengeData, submissionStatus) {
146+
export function checkSolution(solutionState, challengeData, submissionStatus) {
147147
if (CTFd._functions.challenge.checkSolution) {
148148
return CTFd._functions.challenge.checkSolution(
149149
solutionState,
@@ -153,8 +153,9 @@ export async function checkSolution(solutionState, challengeData, submissionStat
153153
}
154154
if (solutionState == "hidden" || solutionState == "visible") {
155155
return false;
156-
} else if (solutionState == "solved" && submissionStatus === "correct") {
157-
return true;
156+
} else if (solutionState == "solved") {
157+
// If solutionState is solved we should check if the user got their submission right
158+
return submissionStatus === "correct";
158159
} else {
159160
// We default to true in case there is a solution state that we are not aware of
160161
return true;

0 commit comments

Comments
 (0)