mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 17:46:28 +08:00
core: fix RecordDetail permission check
This commit is contained in:
1 parent
9be20c5720
commit
ae020bbd93
1 file changed
+4
-5
@@ -165,19 +165,18 @@ class RecordDetailHandler extends ContestDetailBaseHandler {
|
|||||||
canViewCode ||= this.user.hasPriv(PRIV.PRIV_READ_RECORD_CODE);
|
canViewCode ||= this.user.hasPriv(PRIV.PRIV_READ_RECORD_CODE);
|
||||||
canViewCode ||= this.user.hasPerm(PERM.PERM_READ_RECORD_CODE);
|
canViewCode ||= this.user.hasPerm(PERM.PERM_READ_RECORD_CODE);
|
||||||
canViewCode ||= this.user.hasPerm(PERM.PERM_READ_RECORD_CODE_ACCEPT) && self?.status === STATUS.STATUS_ACCEPTED;
|
canViewCode ||= this.user.hasPerm(PERM.PERM_READ_RECORD_CODE_ACCEPT) && self?.status === STATUS.STATUS_ACCEPTED;
|
||||||
if (this.tdoc && this.tdoc.allowViewCode && contest.isDone(this.tdoc)) {
|
if (this.tdoc) {
|
||||||
const tsdoc = await contest.getStatus(domainId, this.tdoc.docId, this.user._id);
|
const tsdoc = await contest.getStatus(domainId, this.tdoc.docId, this.user._id);
|
||||||
|
if (this.tdoc.allowViewCode && contest.isDone(this.tdoc)) {
|
||||||
canViewCode ||= tsdoc?.attend;
|
canViewCode ||= tsdoc?.attend;
|
||||||
}
|
}
|
||||||
|
if (!tsdoc.attend && !problem.canViewBy(pdoc, this.user)) throw new PermissionError(PERM.PERM_VIEW_PROBLEM_HIDDEN);
|
||||||
|
} else if (!problem.canViewBy(pdoc, this.user)) throw new PermissionError(PERM.PERM_VIEW_PROBLEM_HIDDEN);
|
||||||
if (!canViewCode) {
|
if (!canViewCode) {
|
||||||
rdoc.code = '';
|
rdoc.code = '';
|
||||||
rdoc.files = {};
|
rdoc.files = {};
|
||||||
rdoc.compilerTexts = [];
|
rdoc.compilerTexts = [];
|
||||||
} else if (download) return await this.download();
|
} else if (download) return await this.download();
|
||||||
if (pdoc && !(rdoc.contest && this.user._id === rdoc.uid)) {
|
|
||||||
if (!problem.canViewBy(pdoc, this.user)) throw new PermissionError(PERM.PERM_VIEW_PROBLEM_HIDDEN);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.response.template = 'record_detail.html';
|
this.response.template = 'record_detail.html';
|
||||||
this.response.body = {
|
this.response.body = {
|
||||||
udoc, rdoc: canViewDetail ? rdoc : pick(rdoc, ['_id', 'lang', 'code']), pdoc, tdoc: this.tdoc,
|
udoc, rdoc: canViewDetail ? rdoc : pick(rdoc, ['_id', 'lang', 'code']), pdoc, tdoc: this.tdoc,
|
||||||
|
|||||||
Reference in new issue
Block a user