core: update limits

This commit is contained in:
undefined committed 2021-08-07 03:50:39 +08:00
1 parent 738d622225
commit c3190551dd
2 files changed
+7 -4

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "hydrooj", "name": "hydrooj",
"version": "2.32.1", "version": "2.32.2",
"bin": "bin/hydrooj.js", "bin": "bin/hydrooj.js",
"main": "src/loader", "main": "src/loader",
"module": "src/loader", "module": "src/loader",
+6 -3
View File
@@ -113,13 +113,12 @@ class RecordDetailHandler extends Handler {
problem.get(rdoc.pdomain, rdoc.pid), problem.get(rdoc.pdomain, rdoc.pid),
user.getById(domainId, rdoc.uid), user.getById(domainId, rdoc.uid),
]); ]);
if (!rdoc.contest && pdoc.hidden && this.user._id !== rdoc.uid) throw new PermissionError(PERM.PERM_READ_RECORD_CODE);
if ( if (
!pdoc !pdoc
|| !this.user.hasPerm(PERM.PERM_VIEW_PROBLEM) || !this.user.hasPerm(PERM.PERM_VIEW_PROBLEM)
|| (!rdoc.contest && pdoc.hidden && !this.user.own(pdoc) && !this.user.hasPerm(PERM.PERM_VIEW_PROBLEM_HIDDEN)) || (!rdoc.contest && pdoc.hidden && !this.user.own(pdoc) && !this.user.hasPerm(PERM.PERM_VIEW_PROBLEM_HIDDEN))
) { ) {
pdoc = { ...problem.default, docId: pdoc?.docId || 0, pid: '*' }; throw new PermissionError(PERM.PERM_READ_RECORD_CODE);
} }
this.response.body = { udoc, rdoc, pdoc }; this.response.body = { udoc, rdoc, pdoc };
if (rdoc.contest) { if (rdoc.contest) {
@@ -262,7 +261,11 @@ class RecordDetailConnectionHandler extends ConnectionHandler {
} }
} }
const pdoc = await problem.get(rdoc.pdomain, rdoc.pid); const pdoc = await problem.get(rdoc.pdomain, rdoc.pid);
if (!rdoc.contest && pdoc.hidden && this.user._id !== rdoc.uid) throw new PermissionError(PERM.PERM_READ_RECORD_CODE); let canView = this.user.own(pdoc);
canView ||= !pdoc.hidden && this.user.hasPerm(PERM.PERM_VIEW_PROBLEM);
canView ||= this.user.hasPerm(PERM.PERM_VIEW_PROBLEM_HIDDEN);
canView ||= !!rdoc.contest || this.user._id === rdoc.uid;
if (!canView) throw new PermissionError(PERM.PERM_READ_RECORD_CODE);
this.rid = rid.toString(); this.rid = rid.toString();
this.cleanup = bus.on('record/change', this.onRecordChange.bind(this)); this.cleanup = bus.on('record/change', this.onRecordChange.bind(this));
this.onRecordChange(rdoc); this.onRecordChange(rdoc);