From ec31b1df618f381e85a30aec05bd4672b11229b2 Mon Sep 17 00:00:00 2001 From: Noah Date: Fri, 5 Jun 2026 09:51:02 +0200 Subject: [PATCH] Refactor session management and navigation in index and header files; add auth utilities for user role verification --- controllers/auth_utilities.php | 19 +++++++++++++++ index.php | 2 +- views/header.php | 42 +++++++++++++++------------------- 3 files changed, 39 insertions(+), 24 deletions(-) create mode 100644 controllers/auth_utilities.php diff --git a/controllers/auth_utilities.php b/controllers/auth_utilities.php new file mode 100644 index 0000000..3ac21ab --- /dev/null +++ b/controllers/auth_utilities.php @@ -0,0 +1,19 @@ +Accueil'; -if (is_logged()) { - $nav .= '
  • Planning
  • '; - $nav .= '
  • Sauveteurs
  • '; -} -if (has_role('gestionnaire') || has_role('administration')) { - $nav .= '
  • Gestion
  • '; -} -if (has_role('administration')) { - $nav .= '
  • Admin
  • '; -} +// À DÉCOMMENTER quand auth_utilities.php sera chargé : +// $nav .= '
  • Planning
  • '; +// $nav .= '
  • Sauveteurs
  • '; +// $nav .= '
  • Gestion
  • '; +// $nav .= '
  • Admin
  • '; -if (is_logged()) { - $nav .= '
  • Déconnexion
  • '; - $session = 'Connecté : ' . htmlentities($_SESSION['login']) . ' (' . ($_SESSION['role'] ?: 'lecture') . ')'; -} else { - $nav .= '
  • Connexion
  • '; - $session = 'Non connecté'; -} +$nav .= '
  • Planning
  • '; +$nav .= '
  • Sauveteurs
  • '; +$nav .= '
  • Gestion
  • '; +$nav .= '
  • Admin
  • '; + +$nav .= '
  • Connexion
  • '; + +// $session = 'Connecté : ' . htmlentities($_SESSION['login']) . ' (' . ($_SESSION['role'] ?: 'lecture') . ')'; +$session = 'Non connecté'; -// Notification flash $notif = ''; -if (!empty($_SESSION['notification'])) { - $notif = '
    ' . htmlentities($_SESSION['notification']) . '
    '; - unset($_SESSION['notification']); -} +// if (!empty($_SESSION['notification'])) { +// $notif = '
    ' . htmlentities($_SESSION['notification']) . '
    '; +// unset($_SESSION['notification']); +// } ?>