From 5f6e5783628c02f9a12a68751132b9feeaacb2f4 Mon Sep 17 00:00:00 2001 From: Lucie GOIGOUX Date: Sun, 19 Nov 2023 12:17:16 +0100 Subject: [PATCH] ajout de l'absController pour les jeux et les fonctions communes --- Project/php/controller/AbsController.php | 64 ++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 Project/php/controller/AbsController.php diff --git a/Project/php/controller/AbsController.php b/Project/php/controller/AbsController.php new file mode 100644 index 0000000..0dd5f91 --- /dev/null +++ b/Project/php/controller/AbsController.php @@ -0,0 +1,64 @@ +getUser($userID); + echo $twig->render('myAccountView.html', ['user' => $user]); + } + catch (Exception $e){ + throw new Exception("invalid user ID"); + } + } + + public function modifyPassword(): void { + try { + $userID = $_GET['user']; + $currentPassword = Validation::val_password($_GET['currentPassword'] ?? null); + $newPassword = Validation::val_password($_GET['newPassword'] ?? null); + $confirmNewPassword = Validation::val_password($_GET['confirmNewPassword'] ?? null); + $mdl = new MdlStudent(); + $user = $mdl->getUser($userID); + + if ($user->getPassword() != $currentPassword || $newPassword != $confirmNewPassword) + throw new Exception(""); + + $mdl->ModifyPassword($userID, $newPassword); + $_GET['user'] = $userID; + $this->showAccountInfos(); + } + catch (Exception $e){ + throw new Exception("invalid entries"); + } + } + + public function modifyNickname(): void { + try { + $userID = Validation::filter_int($_GET['user'] ?? null); + $newNickname = Validation::filter_str_nospecialchar($_GET['newNickname'] ?? null); + $mdl = new MdlStudent(); + $mdl->modifyNickname($userID, $newNickname); + $_GET['user'] = $userID; + $this->showAccountInfos(); + } + catch (Exception $e){ + throw new Exception("invalid entries"); + } + } + + public function memory(): void{ + global $twig; + } +} \ No newline at end of file