From 2495f231924c5e372c340fb8315164c4061365ce Mon Sep 17 00:00:00 2001 From: Macesuted <57275149+Macesuted@users.noreply.github.com> Date: Sat, 21 Aug 2021 13:18:32 +0800 Subject: [PATCH] core: fix login redirect (#186) --- packages/hydrooj/src/service/server.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/hydrooj/src/service/server.ts b/packages/hydrooj/src/service/server.ts index 05e6ee4db..287f31dea 100644 --- a/packages/hydrooj/src/service/server.ts +++ b/packages/hydrooj/src/service/server.ts @@ -27,6 +27,7 @@ import { UserFacingError, ValidationError, PrivilegeError, CsrfTokenError, InvalidOperationError, MethodNotAllowedError, NotFoundError, HydroError, SystemError, + LoginError, } from '../error'; import { isContent, isName, isTitle } from '../lib/validator'; import avatar from '../lib/avatar'; @@ -650,7 +651,7 @@ 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) { + if (this.user?._id === 0 && !(error instanceof LoginError)) { 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;