mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 17:36:08 +08:00
core: 修复无PERM_VIEW_PROBLEM在user_detail能够查看到题目标题的错误
This commit is contained in:
1 parent
bc3fc23ff3
commit
2328bada9d
3 files changed
+18
-11
No files matched your search
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hydrooj",
|
||||
"version": "2.17.5",
|
||||
"version": "2.17.6",
|
||||
"bin": "bin/hydrooj.js",
|
||||
"main": "dist/loader.js",
|
||||
"typings": "dist/loader.d.ts",
|
||||
|
||||
@@ -143,13 +143,14 @@ class DomainPermissionHandler extends ManageHandler {
|
||||
const roles = {};
|
||||
delete this.request.body.csrfToken;
|
||||
for (const role in this.request.body) {
|
||||
console.log(role, this.request.body[role]);
|
||||
const perms = this.request.body[role] instanceof Array
|
||||
? this.request.body[role]
|
||||
: [this.request.body[role]];
|
||||
// @ts-ignore
|
||||
roles[role] = 0n;
|
||||
// @ts-ignore
|
||||
for (const r of perms) roles[role] += 1n << BigInt(r);
|
||||
for (const r of perms) roles[role] |= 1n << BigInt(r);
|
||||
}
|
||||
await domain.setRoles(domainId, roles);
|
||||
this.back();
|
||||
|
||||
@@ -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 = '';
|
||||
|
||||
Reference in new issue
Block a user