core: optimize permission control for group filter in contest_scoreboard

This commit is contained in:
undefined committed 2024-02-23 07:08:44 +08:00
1 parent 5d4fdb5fc9
commit fe3c32a67e
1 file changed
+5 -3
+5 -3
View File
@@ -328,9 +328,11 @@ export class ContestScoreboardHandler extends ContestDetailBaseHandler {
if (!realtime && this.tdoc.lockAt && !this.tdoc.unlocked) {
config.lockAt = this.tdoc.lockAt;
}
const [, rows, udict, pdict] = await contest.getScoreboard.call(this, domainId, tid, config);
const groups = this.user.hasPerm(PERM.PERM_EDIT_DOMAIN)
? await user.listGroup(domainId) : [];
const allGroups = this.user.hasPerm(PERM.PERM_EDIT_CONTEST_SELF) || (this.user.own(this.tdoc) && this.user.hasPerm(PERM.PERM_EDIT_CONTEST))
const [[, rows, udict, pdict], groups] = await Promise.all([
contest.getScoreboard.call(this, domainId, tid, config),
user.listGroup(domainId, allGroups ? undefined : this.user._id),
]);
// eslint-disable-next-line @typescript-eslint/naming-convention
const page_name = this.tdoc.rule === 'homework'
? 'homework_scoreboard'