diff --git a/controllers/ControllerAdmin.php b/controllers/ControllerAdmin.php index 79dbcf1..3d95772 100644 --- a/controllers/ControllerAdmin.php +++ b/controllers/ControllerAdmin.php @@ -16,6 +16,9 @@ class controllerAdmin { case "goToAdminConnexion": require($vues['adminConnexion']); break; + case "verifValidation": + $this->validationConnexion(); + break; case "ajoutSource": $this->ajoutSource($_REQUEST["linkSource"]); break; @@ -53,6 +56,24 @@ class controllerAdmin { //require('menuAdmin.php'); } + function validationConnexion() { + global $vues; + $validation = new Validation(); + $error =[]; + $validation->val_form($_POST['name'],$_POST['password'],$error); + Foreach ($error as $key) { + print($key); + } + if (empty($error)) { + $MdlAdmin = new MdlAdmin(); + $validation = $MdlAdmin->connection($_POST['name'],$_POST['password']); + if (!empty($validation)) { + echo "toto"; + header("location:".$vues['listeNews']); + } + } + } + function supprimerSource($idSource) { global $con; $mdl = new GatewaySources($con); diff --git a/gateways/gatewayAdmins.php b/gateways/gatewayAdmins.php index d83592b..f2dd3ba 100644 --- a/gateways/gatewayAdmins.php +++ b/gateways/gatewayAdmins.php @@ -12,7 +12,7 @@ class GatewayAdmin { $query = "insert into admin(username,password) values (:username,:password);"; $this->con->executeQuery($query, array(':username' => array($admin->getUsername(), PDO::PARAM_STR), - ':password' => array(hash("sha256",$admin->getPassword()), PDO::PARAM_STR) + ':password' => array(password_hash($admin->getPassword(), PASSWORD_DEFAULT), PDO::PARAM_STR) ) ); } diff --git a/models/MdlAdmin.php b/models/MdlAdmin.php index f13e299..245e361 100644 --- a/models/MdlAdmin.php +++ b/models/MdlAdmin.php @@ -1,24 +1,22 @@ getCredential($login))){ $_SESSION['role']='admin'; $_SESSION['login']=$login; - return new Admin($login,$role); + return new Admin($login,$_SESSION['role']); } else{ return NULL; } } + public function déconnexion(){ session_unset(); session_destroy(); diff --git a/usages/config.php b/usages/config.php index 462d83e..f5c6f2e 100644 --- a/usages/config.php +++ b/usages/config.php @@ -4,6 +4,7 @@ require_once("connection.php"); require_once("models/news.php"); require_once("models/admins.php"); require_once("models/sources.php"); +require_once("models/MdlAdmin.php"); require_once("controllers/ControllerAdmin.php"); @@ -11,6 +12,9 @@ require_once("gateways/gatewayAdmins.php"); require_once("gateways/gatewayNews.php"); require_once("gateways/gatewaySources.php"); +require_once("vues/Validation.php"); + + //préfixe $rep= __DIR__ . '/php/'; //BD diff --git a/vues/Validation.php b/vues/Validation.php index 162fd3d..6bdd2b8 100644 --- a/vues/Validation.php +++ b/vues/Validation.php @@ -39,10 +39,4 @@ } } - $validation = new Validation(); - $error =[]; - $validation->val_form($_POST['name'],$_POST['password'],$error); - Foreach ($error as $key) { - print($key); - } ?> \ No newline at end of file diff --git a/vues/adminConnexion.php b/vues/adminConnexion.php index 9ec462c..05531f7 100644 --- a/vues/adminConnexion.php +++ b/vues/adminConnexion.php @@ -1,6 +1,6 @@ -