mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +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
|
||||
? [] as RecordDoc[]
|
||||
: 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 [udict, pdict] = full ? [{}, {}]
|
||||
: await Promise.all([
|
||||
user.getList(domainId, rdocs.map((rdoc) => rdoc.uid)),
|
||||
canViewProblem
|
||||
? 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 }])),
|
||||
tid
|
||||
? problem.getList(domainId, rdocs.map((rdoc) => rdoc.pid), true, false, problem.PROJECTION_CONTEST_LIST)
|
||||
: 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)) {
|
||||
rdocs = rdocs.map((i) => contest.applyProjection(tdoc, i, this.user));
|
||||
|
||||
Reference in new issue
Block a user