Merge pull request #157 from ThomasRubini/redirect_login

This commit is contained in:
Thomas Rubini 2023-01-26 23:01:15 +01:00 committed by GitHub
commit 764cacdf14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -60,7 +60,16 @@ final class Session
public static function login_or_die()
{
if (!self::is_login()) {
header("Location: /user/login?return_uri=".$_SERVER["REQUEST_URI"]);
$S_uri = null;
// special case: user probably got there from the account button
if (str_starts_with($_SERVER["REQUEST_URI"], "/user/") && isset($_SERVER["HTTP_REFERER"])) {
$S_uri = $_SERVER['HTTP_REFERER'];
} else {
$S_uri = $_SERVER["REQUEST_URI"];
}
header("Location: /user/login?return_uri=".$S_uri);
throw new HTTPSpecialCaseException(403);
}
}