mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 09:46:28 +08:00
core: move notfound error handle pos
This commit is contained in:
1 parent
f466f1bb47
commit
3d19e9578c
2 files changed
+4
-2
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hydrooj",
|
"name": "hydrooj",
|
||||||
"version": "3.3.1",
|
"version": "3.3.2",
|
||||||
"bin": "bin/hydrooj.js",
|
"bin": "bin/hydrooj.js",
|
||||||
"main": "src/loader",
|
"main": "src/loader",
|
||||||
"module": "src/loader",
|
"module": "src/loader",
|
||||||
|
|||||||
@@ -504,6 +504,7 @@ export class Handler extends HandlerCommon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async init({ domainId }) {
|
async init({ domainId }) {
|
||||||
|
let error;
|
||||||
if (!argv.options.benchmark && !this.notUsage) await this.limitRate('global', 10, 88);
|
if (!argv.options.benchmark && !this.notUsage) await this.limitRate('global', 10, 88);
|
||||||
const [absoluteDomain, inferDomain, bdoc] = await Promise.all([
|
const [absoluteDomain, inferDomain, bdoc] = await Promise.all([
|
||||||
domain.get(domainId),
|
domain.get(domainId),
|
||||||
@@ -522,7 +523,7 @@ export class Handler extends HandlerCommon {
|
|||||||
this.user = await user.getById('system', this.session.uid);
|
this.user = await user.getById('system', this.session.uid);
|
||||||
if (!this.user) this.user = await user.getById('system', 0);
|
if (!this.user) this.user = await user.getById('system', 0);
|
||||||
this.domain = inferDomain || await domain.get('system');
|
this.domain = inferDomain || await domain.get('system');
|
||||||
throw new NotFoundError(domainId);
|
error = new NotFoundError(domainId);
|
||||||
}
|
}
|
||||||
this.UiContext.domainId = this.domainId;
|
this.UiContext.domainId = this.domainId;
|
||||||
this.UiContext.domain = this.domain;
|
this.UiContext.domain = this.domain;
|
||||||
@@ -542,6 +543,7 @@ export class Handler extends HandlerCommon {
|
|||||||
icon: global.Hydro.lib[key].icon,
|
icon: global.Hydro.lib[key].icon,
|
||||||
text: global.Hydro.lib[key].text,
|
text: global.Hydro.lib[key].text,
|
||||||
}));
|
}));
|
||||||
|
if (error) throw error;
|
||||||
if (bdoc) throw new BlacklistedError(this.request.ip);
|
if (bdoc) throw new BlacklistedError(this.request.ip);
|
||||||
if (!this.noCheckPermView && !this.user.hasPriv(PRIV.PRIV_VIEW_ALL_DOMAIN)) this.checkPerm(PERM.PERM_VIEW);
|
if (!this.noCheckPermView && !this.user.hasPriv(PRIV.PRIV_VIEW_ALL_DOMAIN)) this.checkPerm(PERM.PERM_VIEW);
|
||||||
if (this.request.method === 'post' && this.request.headers.referer) {
|
if (this.request.method === 'post' && this.request.headers.referer) {
|
||||||
|
|||||||
Reference in new issue
Block a user