correctly redirect to last-page if session is timed out and remove passing script/qrystr url parameters
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -77,6 +77,7 @@ if (($page == 'admins' || $page == 'overview') && $userinfo['change_serversettin
|
||||
$result['switched_user'] = CurrentUser::getData();
|
||||
$result['adminsession'] = 1;
|
||||
$result['userid'] = $result['adminid'];
|
||||
session_regenerate_id(true);
|
||||
CurrentUser::setData($result);
|
||||
|
||||
$log->logAction(
|
||||
|
||||
@@ -94,7 +94,7 @@ if (($page == 'customers' || $page == 'overview') && $userinfo['customers'] != '
|
||||
$result['switched_user'] = CurrentUser::getData();
|
||||
$result['adminsession'] = 0;
|
||||
$result['userid'] = $result['customerid'];
|
||||
session_regenerate_id();
|
||||
session_regenerate_id(true);
|
||||
CurrentUser::setData($result);
|
||||
|
||||
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_INFO, "switched user and is now '" . $destination_user . "'");
|
||||
|
||||
@@ -53,7 +53,7 @@ if ($action == 'logout') {
|
||||
if (is_array(CurrentUser::getField('switched_user'))) {
|
||||
$result = CurrentUser::getData();
|
||||
$result = $result['switched_user'];
|
||||
session_regenerate_id();
|
||||
session_regenerate_id(true);
|
||||
CurrentUser::setData($result);
|
||||
$target = (isset($_GET['target']) ? $_GET['target'] : 'index');
|
||||
$redirect = "admin_" . $target . ".php";
|
||||
|
||||
19
index.php
19
index.php
@@ -434,8 +434,13 @@ if ($action == '2fa_entercode') {
|
||||
if (isset($_REQUEST['qrystr']) && $_REQUEST['qrystr'] != "") {
|
||||
$lastqrystr = urlencode($_REQUEST['qrystr']);
|
||||
}
|
||||
$_SESSION['lastscript'] = $lastscript;
|
||||
$_SESSION['lastqrystr'] = $lastqrystr;
|
||||
|
||||
if (!empty($lastscript)) {
|
||||
$_SESSION['lastscript'] = $lastscript;
|
||||
}
|
||||
if (!empty($lastqrystr)) {
|
||||
$_SESSION['lastqrystr'] = $lastqrystr;
|
||||
}
|
||||
|
||||
UI::view('login/login.html.twig', [
|
||||
'pagetitle' => 'Login',
|
||||
@@ -634,7 +639,7 @@ if ($action == 'forgotpwd') {
|
||||
|
||||
UI::view('login/fpwd.html.twig', [
|
||||
'pagetitle' => lng('login.presend'),
|
||||
'formaction' => 'index.php?action='.$action,
|
||||
'formaction' => 'index.php?action=' . $action,
|
||||
'message' => $message,
|
||||
]);
|
||||
}
|
||||
@@ -786,7 +791,7 @@ if ($action == 'll') {
|
||||
function finishLogin($userinfo)
|
||||
{
|
||||
if (isset($userinfo['userid']) && $userinfo['userid'] != '') {
|
||||
session_regenerate_id();
|
||||
session_regenerate_id(true);
|
||||
CurrentUser::setData($userinfo);
|
||||
|
||||
$language = $userinfo['def_language'] ?? Settings::Get('panel.standardlanguage');
|
||||
@@ -800,7 +805,7 @@ function finishLogin($userinfo)
|
||||
}
|
||||
|
||||
$qryparams = [];
|
||||
if (isset($_SESSION['lastqrystr']) && !empty($_SESSION['lastqrystr'])) {
|
||||
if (!empty($_SESSION['lastqrystr'])) {
|
||||
parse_str(urldecode($_SESSION['lastqrystr']), $qryparams);
|
||||
unset($_SESSION['lastqrystr']);
|
||||
}
|
||||
@@ -809,7 +814,7 @@ function finishLogin($userinfo)
|
||||
if (Froxlor::hasUpdates() || Froxlor::hasDbUpdates()) {
|
||||
Response::redirectTo('admin_updates.php?page=overview');
|
||||
} else {
|
||||
if (isset($_SESSION['lastscript']) && !empty($_SESSION['lastscript'])) {
|
||||
if (!empty($_SESSION['lastscript'])) {
|
||||
$lastscript = $_SESSION['lastscript'];
|
||||
unset($_SESSION['lastscript']);
|
||||
if (preg_match("/customer\_/", $lastscript) === 1) {
|
||||
@@ -824,7 +829,7 @@ function finishLogin($userinfo)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (isset($_SESSION['lastscript']) && !empty($_SESSION['lastscript'])) {
|
||||
if (!empty($_SESSION['lastscript'])) {
|
||||
$lastscript = $_SESSION['lastscript'];
|
||||
unset($_SESSION['lastscript']);
|
||||
Response::redirectTo($lastscript, $qryparams);
|
||||
|
||||
@@ -290,7 +290,8 @@ class UI
|
||||
];
|
||||
}
|
||||
|
||||
public static function validateThemeTemplate(string $name, string $theme = "") {
|
||||
public static function validateThemeTemplate(string $name, string $theme = "")
|
||||
{
|
||||
if (empty(trim($theme))) {
|
||||
$theme = self::getTheme();
|
||||
}
|
||||
|
||||
15
lib/init.php
15
lib/init.php
@@ -181,8 +181,10 @@ if (@file_exists('templates/' . $theme . '/config.json')) {
|
||||
}
|
||||
|
||||
// check for existence of variant in theme
|
||||
if (is_array($_themeoptions) && (!array_key_exists('variants', $_themeoptions) || !array_key_exists($themevariant,
|
||||
$_themeoptions['variants']))) {
|
||||
if (is_array($_themeoptions) && (!array_key_exists('variants', $_themeoptions) || !array_key_exists(
|
||||
$themevariant,
|
||||
$_themeoptions['variants']
|
||||
))) {
|
||||
$themevariant = "default";
|
||||
}
|
||||
|
||||
@@ -216,12 +218,11 @@ UI::twig()->addGlobal('header_logo', $header_logo);
|
||||
if (!CurrentUser::hasSession() && AREA != 'login') {
|
||||
unset($_SESSION['userinfo']);
|
||||
CurrentUser::setData();
|
||||
session_destroy();
|
||||
$params = [
|
||||
"script" => basename($_SERVER["SCRIPT_NAME"]),
|
||||
"qrystr" => $_SERVER["QUERY_STRING"]
|
||||
$_SESSION = [
|
||||
"lastscript" => basename($_SERVER["SCRIPT_NAME"]),
|
||||
"lastqrystr" => $_SERVER["QUERY_STRING"]
|
||||
];
|
||||
Response::redirectTo('index.php', $params);
|
||||
Response::redirectTo('index.php');
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user