core: update redirect

This commit is contained in:
undefined committed 2021-08-23 13:37:18 +08:00
1 parent bff83350a0
commit 979cc6a1bd
2 files changed
+3 -3

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "hydrooj",
"version": "2.33.3",
"version": "2.33.4",
"bin": "bin/hydrooj.js",
"main": "src/loader",
"module": "src/loader",
+2 -2
View File
@@ -651,13 +651,13 @@ export class Handler extends HandlerCommon {
logger.error(`User: ${this.user._id}(${this.user.uname}) Path: ${this.request.path}`, error.msg(), error.params);
if (error.stack) logger.error(error.stack);
}
if (this.user?._id === 0 && !(error instanceof LoginError) && !(error instanceof NotFoundError)) {
if (this.user?._id === 0 && (error instanceof PermissionError || error instanceof PrivilegeError)) {
this.response.redirect = this.url('user_login', { query: { redirect: this.request.path + this.ctx.search } });
} else {
this.response.status = error instanceof UserFacingError ? error.code : 500;
this.response.template = error instanceof UserFacingError ? 'error.html' : 'bsod.html';
this.response.body = {
error: { message: error.msg(), params: error.params, stack: errorMessage(error.stack) },
error: { message: error.msg(), params: error.params, stack: errorMessage(error.stack || '') },
};
}
await this.finish().catch(() => { });