core: fix contest record_list problem permission check

This commit is contained in:
undefined committed 2025-12-23 23:57:01 +08:00
1 parent d44d6d4f83
commit 2596f9db9b
1 file changed
+5 -4
+5 -4
View File
@@ -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));