From a30028947fb9dbdf714b43db1f19cc5ef59a39d9 Mon Sep 17 00:00:00 2001 From: richie Date: Fri, 28 Jun 2019 20:03:23 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=B7=B1=E7=9A=84=E6=8F=90=E4=BA=A4?= =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E9=87=8D=E6=96=B0=E5=88=A4=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/submission.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/modules/submission.js b/modules/submission.js index c579efb..2404e8a 100644 --- a/modules/submission.js +++ b/modules/submission.js @@ -194,7 +194,7 @@ app.get('/submission/:id', async (req, res) => { let currentConfig = Object.assign({}, displayConfig); - currentConfig.showRejudge = await judge.problem.isAllowedEditBy(res.locals.user); + currentConfig.showRejudge = isAuthor || await judge.problem.isAllowedEditBy(res.locals.user, judge.user_id); if (isAdmin || isAuthor) { currentConfig.showShare = true; } @@ -230,11 +230,15 @@ app.post('/submission/:id/rejudge', async (req, res) => { let id = parseInt(req.params.id); let judge = await JudgeState.findById(id); - if (judge.pending && !(res.locals.user && await res.locals.user.hasPrivilege('manage_problem'))) throw new ErrorMessage('无法重新评测一个评测中的提交。'); + let curUser = res.locals.user; + + if (judge.pending && !(curUser && await curUser.hasPrivilege('manage_problem'))) throw new ErrorMessage('无法重新评测一个评测中的提交。'); await judge.loadRelationships(); - let allowedRejudge = await judge.problem.isAllowedEditBy(res.locals.user); + let isAuthor = curUser === null ? false : curUser.id === judge.user_id; + + let allowedRejudge = isAuthor || await judge.problem.isAllowedEditBy(res.locals.user, judge.user_id); if (!allowedRejudge) throw new ErrorMessage('您没有权限进行此操作。'); await judge.rejudge();