From d6fdff6588f3f95f191ab58ddf37949bd81f7705 Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Wed, 1 Feb 2023 20:03:02 +0800 Subject: [PATCH] fix(login): return url --- web/app/controllers/login.php | 2 +- web/app/libs/uoj-html-lib.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/web/app/controllers/login.php b/web/app/controllers/login.php index f5d924c..ff806b9 100644 --- a/web/app/controllers/login.php +++ b/web/app/controllers/login.php @@ -135,7 +135,7 @@ if (isset($_POST['login'])) { $('#help-username, #help-passwor, #help-captcha').html(''); if (msg == 'ok') { - var prevUrl = document.referrer; + var prevUrl = new URLSearchParams(location.search).get('to') || document.referrer; if (prevUrl == '' || /.*\/login.*/.test(prevUrl) || /.*\/logout.*/.test(prevUrl) || /.*\/register.*/.test(prevUrl) || /.*\/reset_password.*/.test(prevUrl)) { prevUrl = '/'; }; diff --git a/web/app/libs/uoj-html-lib.php b/web/app/libs/uoj-html-lib.php index a8224fa..0fa2ddb 100644 --- a/web/app/libs/uoj-html-lib.php +++ b/web/app/libs/uoj-html-lib.php @@ -69,9 +69,9 @@ function permanentlyRedirectToHTTP() { } function redirectToLogin() { if (UOJContext::isAjax()) { - die('please login'); + die('please login'); } else { - header('Location: ' . HTML::url('/login')); + header('Location: ' . HTML::url('/login', ['params' => ['to' => UOJContext::requestPath()]])); die(); } }