Files
ms1inscription-v5/superadm/php/inc_start_time.php
stephan c7482016ce Implement superadmin login redirection and session handling improvements
This commit introduces a new function, `fxSuperadmRedirectToLoginIfNeeded`, to streamline the login redirection process for superadmin users. It enhances session management by checking for user authentication and allowing legacy account access under specific conditions. Additionally, the login flow is updated to ensure users are redirected appropriately after login, improving the overall security and user experience in the superadmin interface. These changes aim to enhance maintainability and clarity in session handling across various superadmin pages.
2026-07-07 14:15:48 -04:00

31 lines
1.0 KiB
PHP

<?php
session_start();
// Meme duree que le site public (MSIN-CON-259)
require_once dirname(__FILE__) . '/inc_functions.php';
$intUsaId = fxSuperadmSessionValidate(true);
if ($intUsaId > 0) {
// session superadm valide — logged rafraîchi
} elseif (!empty($_SESSION['usa_id'])) {
header('Location: logout.php');
exit;
} elseif (!empty($_SESSION['logged'])) {
if ((time() - intval($_SESSION['logged'])) > fxSuperadmSessionInactiveSeconds()) {
header('Location: logout.php');
exit;
}
$_SESSION['logged'] = time();
}
// Session absente → login superadm (pas « Accès refusé »). Rapports legacy : com_info suffit.
$strScript = basename($_SERVER['SCRIPT_NAME'] ?? '');
$tabPublicScripts = array('login.php', 'perdu.php', 'logout.php');
$blnAllowCompteLegacy = ($strScript === 'rapport_new.php')
|| ($strScript === 'index.php' && (($_GET['a'] ?? '') === 'report'));
if (!in_array($strScript, $tabPublicScripts, true)) {
fxSuperadmRedirectToLoginIfNeeded($blnAllowCompteLegacy);
}