From 30ca31ed2bbcdd725cc914a046a287d0606887f5 Mon Sep 17 00:00:00 2001 From: Poty Thomas Date: Mon, 8 Jun 2026 16:04:21 +0200 Subject: [PATCH] =?UTF-8?q?ajout=20de=20la=20foction=20de=20la=20s=C3=A9pa?= =?UTF-8?q?ration=20des=20pages=20selon=20les=20r=C3=B4les?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controllers/auth_ctrl2.php | 16 ++++++- controllers/auth_ctrl2.php~ | 15 +++---- index.php | 6 ++- index.php~ | 85 +++++++++++++++++++++++++++++++++++++ models/connection.php | 2 +- models/connection.php~ | 4 +- models/user_crud.php | 6 +-- models/user_crud.php~ | 16 +++++++ 8 files changed, 131 insertions(+), 19 deletions(-) create mode 100644 index.php~ create mode 100644 models/user_crud.php~ diff --git a/controllers/auth_ctrl2.php b/controllers/auth_ctrl2.php index 875b914..00ddfc7 100644 --- a/controllers/auth_ctrl2.php +++ b/controllers/auth_ctrl2.php @@ -22,7 +22,21 @@ function verify_login_ctrl(?string $route) { session_regenerate_id(true); $_SESSION['login'] = $user['login']; $_SESSION['role'] = $user['type']; - header('Location: index.php?route=' . $route); + if ($route) { + header('Location: index.php?route=' . $route); +} else { + switch ($user['type']) { + case 'admin': + header('Location: index.php?route=admin'); + break; + case 'lecteur': + header('Location: index.php?route=operations'); + break; + default: + header('Location: index.php'); + break; + } +} exit; } else { echo 'Erreur d\'authentification.'; diff --git a/controllers/auth_ctrl2.php~ b/controllers/auth_ctrl2.php~ index 22bf620..875b914 100644 --- a/controllers/auth_ctrl2.php~ +++ b/controllers/auth_ctrl2.php~ @@ -1,11 +1,9 @@ prepare($req); - $prep->bindValue(':id', $id); + $prep->bindValue(':login', $login); $prep->execute(); $auth = $prep->fetch(PDO::FETCH_ASSOC); $prep->closeCursor(); diff --git a/models/user_crud.php~ b/models/user_crud.php~ new file mode 100644 index 0000000..7d36bc9 --- /dev/null +++ b/models/user_crud.php~ @@ -0,0 +1,16 @@ +prepare($req); + $prep->bindValue(':login', $login); + $prep->execute(); + $auth = $prep->fetch(PDO::FETCH_ASSOC); + $prep->closeCursor(); + return $auth; + } + \ No newline at end of file