mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 17:36:08 +08:00
core: update limits
This commit is contained in:
1 parent
738d622225
commit
c3190551dd
2 files changed
+7
-4
No files matched your search
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hydrooj",
|
||||
"version": "2.32.1",
|
||||
"version": "2.32.2",
|
||||
"bin": "bin/hydrooj.js",
|
||||
"main": "src/loader",
|
||||
"module": "src/loader",
|
||||
|
||||
@@ -113,13 +113,12 @@ class RecordDetailHandler extends Handler {
|
||||
problem.get(rdoc.pdomain, rdoc.pid),
|
||||
user.getById(domainId, rdoc.uid),
|
||||
]);
|
||||
if (!rdoc.contest && pdoc.hidden && this.user._id !== rdoc.uid) throw new PermissionError(PERM.PERM_READ_RECORD_CODE);
|
||||
if (
|
||||
!pdoc
|
||||
|| !this.user.hasPerm(PERM.PERM_VIEW_PROBLEM)
|
||||
|| (!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 };
|
||||
if (rdoc.contest) {
|
||||
@@ -262,7 +261,11 @@ class RecordDetailConnectionHandler extends ConnectionHandler {
|
||||
}
|
||||
}
|
||||
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.cleanup = bus.on('record/change', this.onRecordChange.bind(this));
|
||||
this.onRecordChange(rdoc);
|
||||
|
||||
Reference in new issue
Block a user