mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
core: limit sdoc payload
This commit is contained in:
1 parent
22201794ce
commit
340b02bbf2
4 files changed
+8
-11
No files matched your search
+1
-1
@@ -112,7 +112,7 @@ rules:
|
|||||||
no-underscore-dangle: 0
|
no-underscore-dangle: 0
|
||||||
prefer-destructuring: 0
|
prefer-destructuring: 0
|
||||||
function-paren-newline: 0
|
function-paren-newline: 0
|
||||||
simple-import-sort/imports:
|
simple-import-sort/imports:
|
||||||
- warn
|
- warn
|
||||||
- groups:
|
- groups:
|
||||||
- ["^\\u0000"]
|
- ["^\\u0000"]
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hydrooj",
|
"name": "hydrooj",
|
||||||
"version": "3.14.19",
|
"version": "3.14.20",
|
||||||
"bin": "bin/hydrooj.js",
|
"bin": "bin/hydrooj.js",
|
||||||
"main": "src/loader",
|
"main": "src/loader",
|
||||||
"module": "src/loader",
|
"module": "src/loader",
|
||||||
|
|||||||
@@ -294,7 +294,7 @@ class UserDetailHandler extends Handler {
|
|||||||
const isSelfProfile = this.user._id === uid;
|
const isSelfProfile = this.user._id === uid;
|
||||||
const [udoc, sdoc, union] = await Promise.all([
|
const [udoc, sdoc, union] = await Promise.all([
|
||||||
user.getById(domainId, uid),
|
user.getById(domainId, uid),
|
||||||
token.getMostRecentSessionByUid(uid),
|
token.getMostRecentSessionByUid(uid, ['createAt', 'updateAt']),
|
||||||
domain.getUnion(domainId),
|
domain.getUnion(domainId),
|
||||||
]);
|
]);
|
||||||
if (!udoc) throw new UserNotFoundError(uid);
|
if (!udoc) throw new UserNotFoundError(uid);
|
||||||
@@ -319,12 +319,6 @@ class UserDetailHandler extends Handler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
const tags = Object.entries(acInfo).sort((a, b) => b[1] - a[1]).slice(0, 20);
|
const tags = Object.entries(acInfo).sort((a, b) => b[1] - a[1]).slice(0, 20);
|
||||||
// Remove sensitive data
|
|
||||||
if (!isSelfProfile && sdoc) {
|
|
||||||
sdoc.createIp = '';
|
|
||||||
sdoc.updateIp = '';
|
|
||||||
sdoc._id = '';
|
|
||||||
}
|
|
||||||
this.response.template = 'user_detail.html';
|
this.response.template = 'user_detail.html';
|
||||||
this.response.body = {
|
this.response.body = {
|
||||||
isSelfProfile, udoc, sdoc, pdocs, tags,
|
isSelfProfile, udoc, sdoc, pdocs, tags,
|
||||||
|
|||||||
@@ -82,8 +82,11 @@ class TokenModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@ArgMethod
|
@ArgMethod
|
||||||
static async getMostRecentSessionByUid(uid: number) {
|
static async getMostRecentSessionByUid(uid: number, projection: string[]) {
|
||||||
return await TokenModel.coll.findOne({ uid, tokenType: TokenModel.TYPE_SESSION }, { sort: { updateAt: -1 } });
|
return await TokenModel.coll.findOne(
|
||||||
|
{ uid, tokenType: TokenModel.TYPE_SESSION },
|
||||||
|
{ projection: { _id: 0, ...Object.fromEntries(projection.map((i) => [i, 1])) }, sort: { updateAt: -1 } },
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ArgMethod
|
@ArgMethod
|
||||||
|
|||||||
Reference in new issue
Block a user