diff --git a/Project/php/controller/AdminController.php b/Project/php/controller/AdminController.php index 24882d8..e7e9871 100755 --- a/Project/php/controller/AdminController.php +++ b/Project/php/controller/AdminController.php @@ -104,9 +104,9 @@ class AdminController extends UserController public function addGroup(): void { try { - $num = Validation::filter_int($_GET['num'] ?? null); - $year = Validation::filter_int($_GET['year'] ?? null); - $sector = Validation::filter_str_simple($_GET['sector'] ?? null); + $num = Validation::filter_int($_POST['num'] ?? null); + $year = Validation::filter_int($_POST['year'] ?? null); + $sector = Validation::filter_str_simple($_POST['sector'] ?? null); $model = new MdlAdmin(); $groupID = $model->addGroup($num, $year, $sector); diff --git a/Project/php/controller/UserController.php b/Project/php/controller/UserController.php index a3d9b36..4cc6da4 100755 --- a/Project/php/controller/UserController.php +++ b/Project/php/controller/UserController.php @@ -7,6 +7,7 @@ use Exception; use gateway\TranslationGateway; use gateway\VocabularyListGateway; use model\MdlStudent; +use model\MdlUser; use model\VocabularyList; use model\Translation; @@ -21,32 +22,29 @@ class UserController extends VisitorController 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); + global $user; + $currentPassword = Validation::val_password($_POST['currentPassword'] ?? null); + $newPassword = Validation::val_password($_POST['newPassword'] ?? null); + $confirmNewPassword = Validation::val_password($_POST['confirmNewPassword'] ?? null); - if ($user->getPassword() != $currentPassword || $newPassword != $confirmNewPassword) + if (!password_verify($currentPassword, $user->getPassword()) || $newPassword != $confirmNewPassword) throw new Exception(""); - $mdl->ModifyPassword($userID, $newPassword); - $_GET['user'] = $userID; + $mdl = new MdlUser(); + $mdl->ModifyPassword($user->getId(), password_hash($newPassword, null)); $this->showAccountInfos(); } catch (Exception $e){ - throw new Exception("invalid entries"); + throw new Exception("invalid entries".$e->getLine()); } } public function modifyNickname(): void { try { - $userID = Validation::filter_int($_GET['user'] ?? null); - $newNickname = Validation::filter_str_nospecialchar($_GET['newNickname'] ?? null); + global $user; + $newNickname = Validation::filter_str_nospecialchar($_POST['newNickname'] ?? null); $mdl = new MdlStudent(); - $mdl->modifyNickname($userID, $newNickname); - $_GET['user'] = $userID; + $mdl->modifyNickname($user->getId(), $newNickname); $this->showAccountInfos(); } catch (Exception $e){ diff --git a/Project/php/controller/VisitorController.php b/Project/php/controller/VisitorController.php index 78f66cd..3db78b2 100755 --- a/Project/php/controller/VisitorController.php +++ b/Project/php/controller/VisitorController.php @@ -6,6 +6,7 @@ use config\Validation; use gateway\TranslationGateway; use gateway\VocabularyListGateway; use model\MdlUser; +use Exception; class VisitorController { diff --git a/Project/php/model/AbsModel.php b/Project/php/model/AbsModel.php index 5c5f604..3fec615 100755 --- a/Project/php/model/AbsModel.php +++ b/Project/php/model/AbsModel.php @@ -6,16 +6,6 @@ use gateway\UserGateway; abstract class AbsModel { - private string $role; - - /** - * @param string $role - */ - public function __construct(string $role) - { - $this->role = $role; - } - public function connection(string $login, string $password){ $gtw = new UserGateway(); $hash = $gtw->login($login) ?? null; diff --git a/Project/php/model/MdlAdmin.php b/Project/php/model/MdlAdmin.php index a78a7d4..3e607bc 100755 --- a/Project/php/model/MdlAdmin.php +++ b/Project/php/model/MdlAdmin.php @@ -7,10 +7,6 @@ use gateway\UserGateway; class MdlAdmin extends MdlUser { - public function __construct() - { - parent::__construct("admin"); - } public function getAllUsers(): array { $gtw = new UserGateway(); diff --git a/Project/php/model/MdlStudent.php b/Project/php/model/MdlStudent.php index 4333d12..8e7e22c 100755 --- a/Project/php/model/MdlStudent.php +++ b/Project/php/model/MdlStudent.php @@ -8,12 +8,6 @@ use gateway\VocabularyListGateway; class MdlStudent extends MdlUser { - - public function __construct() - { - parent::__construct("student"); - } - public function getAll():array{ $gtw = new VocabularyListGateway(); return $gtw->findAll(); diff --git a/Project/php/model/MdlTeacher.php b/Project/php/model/MdlTeacher.php index 2ee07b0..dd0d273 100755 --- a/Project/php/model/MdlTeacher.php +++ b/Project/php/model/MdlTeacher.php @@ -9,12 +9,6 @@ use gateway\VocabularyListGateway; class MdlTeacher extends MdlUser { - - public function __construct() - { - parent::__construct("teacher"); - } - public function getAll():array{ $gtw = new VocabularyListGateway(); return $gtw->findAll(); diff --git a/Project/php/templates/home.html b/Project/php/templates/home.html index 44fbf8b..016b973 100755 --- a/Project/php/templates/home.html +++ b/Project/php/templates/home.html @@ -34,7 +34,7 @@ diff --git a/Project/php/templates/login.html b/Project/php/templates/login.html index 5c71d25..8326876 100755 --- a/Project/php/templates/login.html +++ b/Project/php/templates/login.html @@ -24,7 +24,7 @@

Log In

-
+
diff --git a/Project/php/templates/modifyPasswordForm.twig b/Project/php/templates/modifyPasswordForm.twig index 817c662..bfcb089 100755 --- a/Project/php/templates/modifyPasswordForm.twig +++ b/Project/php/templates/modifyPasswordForm.twig @@ -1,5 +1,4 @@ - - + diff --git a/Project/php/templates/myAccountView.html b/Project/php/templates/myAccountView.html index d20200b..b12bd2f 100755 --- a/Project/php/templates/myAccountView.html +++ b/Project/php/templates/myAccountView.html @@ -15,7 +15,7 @@ href="https://fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,700,700i,800,800i,900,900i" rel="stylesheet" /> - + +{% include 'navbar.twig' %} +

My account

{% if user is defined %} @@ -32,8 +34,7 @@ ID : {{user.id}} Nickname : {{user.nickname}} - - + @@ -56,5 +57,6 @@ {% include 'modifyPasswordForm.twig' %}
{% endif %} +
\ No newline at end of file