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(); } }