mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: 修复我的域显示遗漏的问题
This commit is contained in:
1 parent
d07dd386cd
commit
2e600b92e5
3 files changed
+8
-2
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hydrooj",
|
"name": "hydrooj",
|
||||||
"version": "2.15.2",
|
"version": "2.15.3",
|
||||||
"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",
|
||||||
|
|||||||
@@ -297,6 +297,7 @@ class HomeDomainCreateHandler extends Handler {
|
|||||||
gravatar = gravatar || this.user.gravatar || this.user.mail || 'guest@hydro.local';
|
gravatar = gravatar || this.user.gravatar || this.user.mail || 'guest@hydro.local';
|
||||||
const domainId = await domain.add(id, this.user._id, name, bulletin);
|
const domainId = await domain.add(id, this.user._id, name, bulletin);
|
||||||
await domain.edit(domainId, { gravatar });
|
await domain.edit(domainId, { gravatar });
|
||||||
|
await domain.setUserRole(domainId, this.user._id, 'admin');
|
||||||
this.response.redirect = this.url('domain_dashboard', { domainId });
|
this.response.redirect = this.url('domain_dashboard', { domainId });
|
||||||
this.response.body = { domainId };
|
this.response.body = { domainId };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -140,6 +140,7 @@ export async function getDomainUser(domainId: string, udoc: DomainUserArg) {
|
|||||||
if (udoc.priv & PRIV.PRIV_MANAGE_ALL_DOMAIN) dudoc.role = 'admin';
|
if (udoc.priv & PRIV.PRIV_MANAGE_ALL_DOMAIN) dudoc.role = 'admin';
|
||||||
dudoc.role = dudoc.role || 'default';
|
dudoc.role = dudoc.role || 'default';
|
||||||
const ddoc = await get(domainId);
|
const ddoc = await get(domainId);
|
||||||
|
if (ddoc.owner === udoc._id) dudoc.role = 'admin';
|
||||||
dudoc.perm = ddoc.roles[dudoc.role]
|
dudoc.perm = ddoc.roles[dudoc.role]
|
||||||
? BigInt(ddoc.roles[dudoc.role])
|
? BigInt(ddoc.roles[dudoc.role])
|
||||||
: BUILTIN_ROLES[dudoc.role];
|
: BUILTIN_ROLES[dudoc.role];
|
||||||
@@ -167,13 +168,17 @@ export async function incUserInDomain(domainId: string, uid: number, field: stri
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function getDictUserByDomainId(uid: number) {
|
export async function getDictUserByDomainId(uid: number) {
|
||||||
const dudocs = await collUser.find({ uid }).toArray();
|
const [dudocs, ddocs] = await Promise.all([
|
||||||
|
collUser.find({ uid }).toArray(),
|
||||||
|
coll.find({ owner: uid }).toArray(),
|
||||||
|
]);
|
||||||
const dudict = {};
|
const dudict = {};
|
||||||
for (const dudoc of dudocs) {
|
for (const dudoc of dudocs) {
|
||||||
// eslint-disable-next-line no-await-in-loop
|
// eslint-disable-next-line no-await-in-loop
|
||||||
dudict[dudoc.domainId] = await get(dudoc.domainId);
|
dudict[dudoc.domainId] = await get(dudoc.domainId);
|
||||||
dudict[dudoc.domainId].role = dudoc.role;
|
dudict[dudoc.domainId].role = dudoc.role;
|
||||||
}
|
}
|
||||||
|
for (const ddoc of ddocs) dudict[ddoc._id] = 'admin';
|
||||||
return dudict;
|
return dudict;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user