core: add showSelfRecord for contest

This commit is contained in:
undefined committed 2021-06-30 17:18:46 +08:00
1 parent 33208a0d1f
commit 3761a5c77d
4 files changed
+20 -3

No files matched your search

+6 -1
View File
@@ -95,7 +95,12 @@ class RecordDetailHandler extends Handler {
if (!rdoc) throw new RecordNotFoundError(rid);
if (rdoc.contest) {
const tdoc = await contest.get(domainId, rdoc.contest.tid, rdoc.contest.type);
if (!contest.canShowRecord.call(this, tdoc, true)) throw new PermissionError(rid);
if (
(rdoc.uid !== this.user._id && !contest.canShowRecord.call(this, tdoc, true))
|| (rdoc.uid === this.user._id && !contest.canShowSelfRecord.call(this, tdoc, true))
) {
throw new PermissionError(rid);
}
}
if (rdoc.uid !== this.user._id && !this.user.hasPriv(PRIV.PRIV_READ_RECORD_CODE)) {
if (!this.user.hasPerm(PERM.PERM_READ_RECORD_CODE)) rdoc.code = null;