core: fix redirect path generation

This commit is contained in:
undefined committed 2022-06-29 00:04:00 +08:00
1 parent 231dee0acd
commit 2b0bd3df04
2 files changed
+6 -2

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "hydrooj", "name": "hydrooj",
"version": "3.14.0", "version": "3.14.1",
"bin": "bin/hydrooj.js", "bin": "bin/hydrooj.js",
"main": "src/loader", "main": "src/loader",
"module": "src/loader", "module": "src/loader",
+5 -1
View File
@@ -236,7 +236,11 @@ export class Handler extends HandlerCommon {
if (error.stack) logger.error(error.stack); if (error.stack) logger.error(error.stack);
} }
if (this.user?._id === 0 && (error instanceof PermissionError || error instanceof PrivilegeError)) { if (this.user?._id === 0 && (error instanceof PermissionError || error instanceof PrivilegeError)) {
this.response.redirect = this.ctx.getUrl('user_login', { query: { redirect: this.request.path + this.ctx.search } }); this.response.redirect = this.ctx.getUrl('user_login', {
query: {
redirect: (this.ctx.originalPath || this.request.path) + this.ctx.search,
},
});
} else { } else {
this.response.status = error instanceof UserFacingError ? error.code : 500; this.response.status = error instanceof UserFacingError ? error.code : 500;
this.response.template = error instanceof UserFacingError ? 'error.html' : 'bsod.html'; this.response.template = error instanceof UserFacingError ? 'error.html' : 'bsod.html';