core: 修复无PERM_VIEW_PROBLEM在user_detail能够查看到题目标题的错误

This commit is contained in:
undefined committed 2021-01-28 13:26:27 +08:00
1 parent bc3fc23ff3
commit 2328bada9d
3 files changed
+18 -11

No files matched your search

+15 -9
View File
@@ -162,16 +162,22 @@ class UserDetailHandler extends Handler {
const [sdoc, rdocs, [pdocs, pcount]] = await Promise.all([
token.getMostRecentSessionByUid(uid),
record.getByUid(domainId, uid, 30),
paginate(
problem.getMulti(domainId, { owner: this.user._id }),
1,
100,
),
this.user.hasPerm(PERM.PERM_VIEW_PROBLEM)
? paginate(
problem.getMulti(domainId, { owner: this.user._id }),
1,
100,
)
: [[], 0, 0] as [problem.Pdoc[], number, number],
]);
const pdict = await problem.getList(
domainId, rdocs.map((rdoc) => rdoc.pid),
this.user.hasPerm(PERM.PERM_VIEW_PROBLEM_HIDDEN), false,
);
const pdict = this.user.hasPerm(PERM.PERM_VIEW_PROBLEM)
? await problem.getList(
domainId, rdocs.map((rdoc) => rdoc.pid),
this.user.hasPerm(PERM.PERM_VIEW_PROBLEM_HIDDEN), false,
)
: Object.fromEntries(rdocs.map(
(rdoc) => [rdoc.pid, problem.Pdoc.create(undefined, rdoc.pid.toString())],
));
// Remove sensitive data
if (!isSelfProfile && sdoc) {
sdoc.createIp = '';