mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
bug fixes
This commit is contained in:
20 files changed
+43
-35
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import { KoaContext } from '@hydrooj/framework';
|
||||
import { KoaContext, NotFoundError } from '@hydrooj/framework';
|
||||
import BlackListModel from '../../model/blacklist';
|
||||
import DomainModel from '../../model/domain';
|
||||
import * as system from '../../model/system';
|
||||
@@ -24,5 +24,12 @@ export default async (ctx: KoaContext, next) => {
|
||||
ctx.domainId = inferDomain?._id || domainId;
|
||||
ctx.domainInfo = inferDomain || absoluteDomain;
|
||||
if (ctx.domainInfo && ctx.domainId !== ctx.domainInfo._id) ctx.redirect(ctx.originalPath.replace(/^\/d\/[^/]+\//, `/d/${ctx.domainInfo._id}/`));
|
||||
else await next();
|
||||
else {
|
||||
if (!ctx.domainInfo) {
|
||||
ctx.pendingError = new NotFoundError(ctx.domainId);
|
||||
ctx.domainId = 'system';
|
||||
ctx.domainInfo = await DomainModel.get('system');
|
||||
}
|
||||
await next();
|
||||
}
|
||||
};
|
||||
@@ -1,5 +1,4 @@
|
||||
import type { KoaContext } from '@hydrooj/framework';
|
||||
import { NotFoundError } from '../../error';
|
||||
import { PERM } from '../../model/builtin';
|
||||
import UserModel from '../../model/user';
|
||||
|
||||
@@ -15,9 +14,5 @@ export default async (ctx: KoaContext, next) => {
|
||||
}
|
||||
if (user._id === 0) delete user.viewLang;
|
||||
ctx.HydroContext.user = await user.private();
|
||||
if (!domain) {
|
||||
ctx.pendingError = new NotFoundError(args.domainId);
|
||||
args.domainId = 'system';
|
||||
}
|
||||
await next();
|
||||
};
|
||||
Reference in new issue
Block a user