From dd6da017909275cce325615fa05779c5d08e7344 Mon Sep 17 00:00:00 2001 From: Zisu Zhang Date: Sun, 31 Mar 2024 16:01:25 +0800 Subject: [PATCH] chore(server): allow admin bypass rules (#88) --- .yarn/versions/f97c48cf.yml | 2 ++ apps/server/src/routes/contest/solution/index.ts | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 .yarn/versions/f97c48cf.yml diff --git a/.yarn/versions/f97c48cf.yml b/.yarn/versions/f97c48cf.yml new file mode 100644 index 0000000..51ebf65 --- /dev/null +++ b/.yarn/versions/f97c48cf.yml @@ -0,0 +1,2 @@ +releases: + "@aoi-js/server": 1.1.0-alpha.6 diff --git a/apps/server/src/routes/contest/solution/index.ts b/apps/server/src/routes/contest/solution/index.ts index 173a950..e1d8e39 100644 --- a/apps/server/src/routes/contest/solution/index.ts +++ b/apps/server/src/routes/contest/solution/index.ts @@ -217,7 +217,7 @@ const solutionScopedRoutes = defineRoutes(async (s) => { }) if (!solution) throw s.httpErrors.notFound() const { solutionShowOtherData } = ctx._contestStage.settings - let showData = checkUser(req, solution.userId, solutionShowOtherData) + let showData = !!solutionShowOtherData if (ctx._contest.rules?.solution) { ;({ showData } = solutionRuleEvaluator( { @@ -232,7 +232,7 @@ const solutionScopedRoutes = defineRoutes(async (s) => { { showData } )) } - if (!showData) throw s.httpErrors.forbidden() + if (!checkUser(req, solution.userId, showData)) throw s.httpErrors.forbidden() return [ctx._contest.orgId, solutionDataKey(solution._id)] }, allowedTypes: ['download']