core: allow user with PERM_VIEW_PROBLEM_HIDDEN view all problems

This commit is contained in:
undefined committed 2022-01-15 11:42:39 +08:00
1 parent 9a2256fb0d
commit ecde94fee5
3 files changed
+4 -3

No files matched your search

+2 -1
View File
@@ -366,7 +366,8 @@ export class ProblemModel {
static canViewBy(pdoc: ProblemDoc, udoc: User) {
if (!udoc.hasPerm(PERM.PERM_VIEW_PROBLEM)) return false;
if (udoc.own(pdoc)) return true;
if (pdoc.hidden && !udoc.hasPerm(PERM.PERM_VIEW_PROBLEM_HIDDEN)) return false;
if (udoc.hasPerm(PERM.PERM_VIEW_PROBLEM_HIDDEN)) return true;
if (pdoc.hidden) return false;
if (!pdoc.assign.length) return true;
return !!Set.intersection(pdoc.assign, udoc.group).size;
}