From 377ed6a346e8fe758ca19bd0b09f2189b9709ac7 Mon Sep 17 00:00:00 2001 From: Noah Date: Wed, 10 Jun 2026 20:32:22 +0200 Subject: [PATCH] =?UTF-8?q?Authentification=20fonctionnelle=20avec=20prote?= =?UTF-8?q?ction=20des=20pages=20par=20r=C3=B4le?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Page de connexion par défaut. Redirections post-login selon le rôle. Navigation header adaptée au profil connecté. Protection des routes : opérations (gestionnaire+admin), gestion comptes (admin), planning (tous). Notifications et barre de session activées. --- controllers/auth_ctrl2.php | 64 ++++++++++++++++++++----------- controllers/auth_utilities.php | 9 +++++ controllers/contact_crtl.php | 5 +++ controllers/lecture_page_ctrl.php | 2 + controllers/modif_compte_ctrl.php | 4 ++ controllers/operation_ctrl.php | 10 +++++ controllers/utilisateur_ctrl.php | 4 ++ index.php | 15 +++++--- models/user_crud.php | 2 +- views/header.php | 54 +++++++++++++------------- 10 files changed, 113 insertions(+), 56 deletions(-) diff --git a/controllers/auth_ctrl2.php b/controllers/auth_ctrl2.php index 9e94da3..8d7d65b 100644 --- a/controllers/auth_ctrl2.php +++ b/controllers/auth_ctrl2.php @@ -1,5 +1,7 @@ Accueil'; -$nav .= '
  • Opérations
  • '; -$nav .= '
  • Gestion des comptes
  • '; +// --- NAVIGATION selon le rôle --- +$nav = ''; -// À DÉCOMMENTER quand l'auth sera fonctionnelle : -// if (is_logged()) { -// $nav .= '
  • Planning
  • '; -// $nav .= '
  • Sauveteurs
  • '; -// } -// if (has_role('gestionnaire') || has_role('administration')) { -// $nav .= '
  • Gestion
  • '; -// } -// if (has_role('administration')) { -// $nav .= '
  • Admin
  • '; -// } -// if (is_logged()) { -// $nav .= '
  • Déconnexion
  • '; -// } else { -// $nav .= '
  • Connexion
  • '; -// } +if (is_logged()) { + $nav .= '
  • Accueil
  • '; -// $session = 'Connecté : ' . htmlentities($_SESSION['login']) . ' (' . ($_SESSION['role'] ?: 'lecture') . ')'; -$session = 'Non connecté'; + if (has_any_role(['gestionnaire', 'administration'])) { + $nav .= '
  • Opérations
  • '; + } + if (has_role('administration')) { + $nav .= '
  • Gestion des comptes
  • '; + } + + $nav .= '
  • Déconnexion
  • '; +} + +// --- BARRE DE SESSION --- +if (is_logged()) { + $session = 'Connecté : ' . htmlentities($_SESSION['login']) . ' (' . htmlentities($_SESSION['role']) . ')'; +} else { + $session = 'Non connecté'; +} + +// --- NOTIFICATION --- $notif = ''; -// if (!empty($_SESSION['notification'])) { -// $notif = '
    ' . htmlentities($_SESSION['notification']) . '
    '; -// unset($_SESSION['notification']); -// } +if (!empty($_SESSION['notification'])) { + $notif = '
    ' . htmlentities($_SESSION['notification']) . '
    '; + unset($_SESSION['notification']); +} ?>