bug fixes

This commit is contained in:
undefined committed 2024-06-27 03:58:29 +08:00
1 parent 16b6f53653
commit 84f7d5dc80
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();
};
+1
View File
@@ -276,6 +276,7 @@ export async function apply(ctx: Context) {
text: global.Hydro.module.oauth[key].text,
}));
if (!h.noCheckPermView && !h.user.hasPriv(PRIV.PRIV_VIEW_ALL_DOMAIN)) h.checkPerm(PERM.PERM_VIEW);
if (h.context.pendingError) throw h.context.pendingError;
});
on('app/listen', () => {