Merge remote-tracking branch 'origin/master'

# Conflicts:
#	models/MdlAdmin.php
master
Bastien OLLIER 3 years ago
commit ad5ac6076e

@ -16,6 +16,9 @@ class controllerAdmin {
case "goToAdminConnexion": case "goToAdminConnexion":
require($vues['adminConnexion']); require($vues['adminConnexion']);
break; break;
case "verifValidation":
$this->validationConnexion();
break;
case "ajoutSource": case "ajoutSource":
$this->ajoutSource($_REQUEST["linkSource"]); $this->ajoutSource($_REQUEST["linkSource"]);
break; break;
@ -63,6 +66,24 @@ class controllerAdmin {
//require('menuAdmin.php'); //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) { function supprimerSource($idSource) {
global $con; global $con;
$mdl = new GatewaySources($con); $mdl = new GatewaySources($con);

@ -12,7 +12,7 @@ class GatewayAdmin
{ {
$query = "insert into admin(username,password) values (:username,:password);"; $query = "insert into admin(username,password) values (:username,:password);";
$this->con->executeQuery($query, array(':username' => array($admin->getUsername(), PDO::PARAM_STR), $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)
) )
); );
} }

@ -1,4 +1,8 @@
<?php <?php
require('gatewayAdmins.php');
require('config.php');
class MdlAdmin class MdlAdmin
{ {
public function connection($login, $mdp){ public function connection($login, $mdp){

@ -4,6 +4,7 @@ require_once("connection.php");
require_once("models/news.php"); require_once("models/news.php");
require_once("models/admins.php"); require_once("models/admins.php");
require_once("models/sources.php"); require_once("models/sources.php");
require_once("models/MdlAdmin.php");
require_once("controllers/ControllerAdmin.php"); require_once("controllers/ControllerAdmin.php");
@ -11,6 +12,9 @@ require_once("gateways/gatewayAdmins.php");
require_once("gateways/gatewayNews.php"); require_once("gateways/gatewayNews.php");
require_once("gateways/gatewaySources.php"); require_once("gateways/gatewaySources.php");
require_once("vues/Validation.php");
//préfixe //préfixe
$rep= __DIR__ . '/php/'; $rep= __DIR__ . '/php/';
//BD //BD

@ -39,10 +39,4 @@
} }
} }
$validation = new Validation();
$error =[];
$validation->val_form($_POST['name'],$_POST['password'],$error);
Foreach ($error as $key) {
print($key);
}
?> ?>

@ -1,6 +1,6 @@
<!doctype html> <!doctype html>
<html> <html>
<form action="Validation.php" method="POST"> <form action="index.php?action=verifValidation" method="POST">
<input type="text" name="name" placeholder="name" /><br> <input type="text" name="name" placeholder="name" /><br>
<input type="text" name="password" placeholder="password" /> <input type="text" name="password" placeholder="password" />
<input type="submit" value="OK"> <input type="submit" value="OK">

Loading…
Cancel
Save