fix(login): return url

This commit is contained in:
Baoshuo Ren 2023-02-01 20:03:02 +08:00
parent f2f4ae9b4e
commit d6fdff6588
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
2 changed files with 3 additions and 3 deletions

View File

@ -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 = '/';
};

View File

@ -69,9 +69,9 @@ function permanentlyRedirectToHTTP() {
}
function redirectToLogin() {
if (UOJContext::isAjax()) {
die('please <a href="' . HTML::url('/login') . '">login</a>');
die('please <a href="' . HTML::url('/login', ['params' => ['to' => UOJContext::requestPath()]]) . '">login</a>');
} else {
header('Location: ' . HTML::url('/login'));
header('Location: ' . HTML::url('/login', ['params' => ['to' => UOJContext::requestPath()]]));
die();
}
}