mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: 修复无PERM_VIEW_PROBLEM在user_detail能够查看到题目标题的错误
This commit is contained in:
1 parent
bc3fc23ff3
commit
2328bada9d
3 files changed
+13
-6
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hydrooj",
|
"name": "hydrooj",
|
||||||
"version": "2.17.5",
|
"version": "2.17.6",
|
||||||
"bin": "bin/hydrooj.js",
|
"bin": "bin/hydrooj.js",
|
||||||
"main": "dist/loader.js",
|
"main": "dist/loader.js",
|
||||||
"typings": "dist/loader.d.ts",
|
"typings": "dist/loader.d.ts",
|
||||||
|
|||||||
@@ -143,13 +143,14 @@ class DomainPermissionHandler extends ManageHandler {
|
|||||||
const roles = {};
|
const roles = {};
|
||||||
delete this.request.body.csrfToken;
|
delete this.request.body.csrfToken;
|
||||||
for (const role in this.request.body) {
|
for (const role in this.request.body) {
|
||||||
|
console.log(role, this.request.body[role]);
|
||||||
const perms = this.request.body[role] instanceof Array
|
const perms = this.request.body[role] instanceof Array
|
||||||
? this.request.body[role]
|
? this.request.body[role]
|
||||||
: [this.request.body[role]];
|
: [this.request.body[role]];
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
roles[role] = 0n;
|
roles[role] = 0n;
|
||||||
// @ts-ignore
|
// @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);
|
await domain.setRoles(domainId, roles);
|
||||||
this.back();
|
this.back();
|
||||||
|
|||||||
@@ -162,16 +162,22 @@ class UserDetailHandler extends Handler {
|
|||||||
const [sdoc, rdocs, [pdocs, pcount]] = await Promise.all([
|
const [sdoc, rdocs, [pdocs, pcount]] = await Promise.all([
|
||||||
token.getMostRecentSessionByUid(uid),
|
token.getMostRecentSessionByUid(uid),
|
||||||
record.getByUid(domainId, uid, 30),
|
record.getByUid(domainId, uid, 30),
|
||||||
paginate(
|
this.user.hasPerm(PERM.PERM_VIEW_PROBLEM)
|
||||||
|
? paginate(
|
||||||
problem.getMulti(domainId, { owner: this.user._id }),
|
problem.getMulti(domainId, { owner: this.user._id }),
|
||||||
1,
|
1,
|
||||||
100,
|
100,
|
||||||
),
|
)
|
||||||
|
: [[], 0, 0] as [problem.Pdoc[], number, number],
|
||||||
]);
|
]);
|
||||||
const pdict = await problem.getList(
|
const pdict = this.user.hasPerm(PERM.PERM_VIEW_PROBLEM)
|
||||||
|
? await problem.getList(
|
||||||
domainId, rdocs.map((rdoc) => rdoc.pid),
|
domainId, rdocs.map((rdoc) => rdoc.pid),
|
||||||
this.user.hasPerm(PERM.PERM_VIEW_PROBLEM_HIDDEN), false,
|
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
|
// Remove sensitive data
|
||||||
if (!isSelfProfile && sdoc) {
|
if (!isSelfProfile && sdoc) {
|
||||||
sdoc.createIp = '';
|
sdoc.createIp = '';
|
||||||
|
|||||||
Reference in new issue
Block a user