From e2ec8af47b765739ed13a485ad4dabbb6e680157 Mon Sep 17 00:00:00 2001 From: Thomas Rubini <74205383+ThomasRubini@users.noreply.github.com> Date: Thu, 26 Jan 2023 23:00:48 +0100 Subject: [PATCH] Add special case for login redirection --- Modules/Session/Session.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Modules/Session/Session.php b/Modules/Session/Session.php index bf49959..f659897 100644 --- a/Modules/Session/Session.php +++ b/Modules/Session/Session.php @@ -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); } }