mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: fix contest record_list problem permission check
This commit is contained in:
1 file changed
+5
-4
@@ -94,14 +94,15 @@ export class RecordListHandler extends ContestDetailBaseHandler {
|
|||||||
let rdocs = invalid
|
let rdocs = invalid
|
||||||
? [] as RecordDoc[]
|
? [] as RecordDoc[]
|
||||||
: await cursor.skip((page - 1) * limit).limit(limit).toArray();
|
: await cursor.skip((page - 1) * limit).limit(limit).toArray();
|
||||||
const canViewProblem = tid || this.user.hasPerm(PERM.PERM_VIEW_PROBLEM);
|
|
||||||
const canViewHiddenProblem = this.user.hasPerm(PERM.PERM_VIEW_PROBLEM_HIDDEN) || this.user._id;
|
const canViewHiddenProblem = this.user.hasPerm(PERM.PERM_VIEW_PROBLEM_HIDDEN) || this.user._id;
|
||||||
const [udict, pdict] = full ? [{}, {}]
|
const [udict, pdict] = full ? [{}, {}]
|
||||||
: await Promise.all([
|
: await Promise.all([
|
||||||
user.getList(domainId, rdocs.map((rdoc) => rdoc.uid)),
|
user.getList(domainId, rdocs.map((rdoc) => rdoc.uid)),
|
||||||
canViewProblem
|
tid
|
||||||
? problem.getList(domainId, rdocs.map((rdoc) => rdoc.pid), canViewHiddenProblem, false, problem.PROJECTION_LIST)
|
? problem.getList(domainId, rdocs.map((rdoc) => rdoc.pid), true, false, problem.PROJECTION_CONTEST_LIST)
|
||||||
: Object.fromEntries(uniqBy(rdocs, 'pid').map((rdoc) => [rdoc.pid, { ...problem.default, pid: rdoc.pid }])),
|
: this.user.hasPerm(PERM.PERM_VIEW_PROBLEM)
|
||||||
|
? problem.getList(domainId, rdocs.map((rdoc) => rdoc.pid), canViewHiddenProblem, false, problem.PROJECTION_LIST)
|
||||||
|
: Object.fromEntries(uniqBy(rdocs, 'pid').map((rdoc) => [rdoc.pid, { ...problem.default, pid: rdoc.pid }])),
|
||||||
]);
|
]);
|
||||||
if (this.tdoc && !this.user.own(this.tdoc) && !this.user.hasPerm(PERM.PERM_EDIT_CONTEST)) {
|
if (this.tdoc && !this.user.own(this.tdoc) && !this.user.hasPerm(PERM.PERM_EDIT_CONTEST)) {
|
||||||
rdocs = rdocs.map((i) => contest.applyProjection(tdoc, i, this.user));
|
rdocs = rdocs.map((i) => contest.applyProjection(tdoc, i, this.user));
|
||||||
|
|||||||
Reference in new issue
Block a user