Lucie Bedouret 3 years ago
commit e1f8669426

BIN
.DS_Store vendored

Binary file not shown.

@ -6,10 +6,20 @@
$dataVueEreur[] ="Nom d'utilisateur manquant"; $dataVueEreur[] ="Nom d'utilisateur manquant";
throw new Exception('pas de username'); throw new Exception('pas de username');
} }
$usrName = Validation::clear_string($usrName);
if($usrName == false){
$dataVueEreur[] = "Sanitizing error";
throw new Exception('sanitizing fail');
}
if (!isset($mdp)||$mdp=="") { if (!isset($mdp)||$mdp=="") {
$dataVueEreur[] ="Mot de passe manquant"; $dataVueEreur[] ="Mot de passe manquant";
throw new Exception('pas de password'); throw new Exception('pas de password');
} }
$mdp = Validation::clear_string($mdp);
if($mdp == false){
$dataVueEreur[] = "Sanitizing error";
throw new Exception('sanitizing fail');
}
return $dataVueEreur; return $dataVueEreur;
} }
@ -18,14 +28,29 @@
$dataVueEreur[] ="Nom d'utilisateur manquant"; $dataVueEreur[] ="Nom d'utilisateur manquant";
throw new Exception('pas de username'); throw new Exception('pas de username');
} }
$username = Validation::clear_string($username);
if($username == false){
$dataVueEreur[] = "Sanitizing error";
throw new Exception('sanitizing fail');
}
if (!isset($pwd1)||$pwd1==="") { if (!isset($pwd1)||$pwd1==="") {
$dataVueEreur[] ="Mot de passe manquant"; $dataVueEreur[] ="Mot de passe manquant";
throw new Exception('pas de password'); throw new Exception('pas de password');
} }
$pwd1 = Validation::clear_string($pwd1);
if($pwd1 == false){
$dataVueEreur[] = "Sanitizing error";
throw new Exception('sanitizing fail');
}
if (!isset($pwd2)||$pwd2==="") { if (!isset($pwd2)||$pwd2==="") {
$dataVueEreur[] ="Confirmation mot de passe manquant"; $dataVueEreur[] ="Confirmation mot de passe manquant";
throw new Exception('pas de confirmation password'); throw new Exception('pas de confirmation password');
} }
$pwd2 = Validation::clear_string($pwd2);
if($pwd2 == false){
$dataVueEreur[] = "Sanitizing error";
throw new Exception('sanitizing fail');
}
if($pwd1 !== $pwd2){ if($pwd1 !== $pwd2){
$dataVueEreur[]="Mot de passe et confirmation différents"; $dataVueEreur[]="Mot de passe et confirmation différents";
throw new Exception("Mot de passe et confirmation différents"); throw new Exception("Mot de passe et confirmation différents");
@ -33,8 +58,21 @@
return $dataVueEreur; return $dataVueEreur;
} }
static function val_intitule($intitule, $dataVueEreur){
if (!isset($intitule)||$intitule==="") {
$dataVueEreur[] ="Intitulé manquant";
throw new Exception('pas d\'intitule');
}
$intitule = Validation::clear_string($intitule);
if($intitule == false){
$dataVueEreur[] = "Sanitizing error";
throw new Exception('sanitizing fail');
}
return $dataVueEreur;
}
static function clear_string($champ){ static function clear_string($champ){
// A changer filter_var return filter_var($champ, FILTER_SANITIZE_SPECIAL_CHARS);
} }
} }

@ -3,7 +3,7 @@
//Prefixe //Prefixe
$rep=__DIR__.'/../'; $rep=__DIR__.'/../';
//BD //BD
$bd['dsn'] = "mysql:host=localhost;port=8888;dbname=dbPhp"; $bd['dsn'] = "mysql:host=localhost;port=8888;dbname=bdPhp";
$bd['user'] = "root"; $bd['user'] = "root";
$bd['pswd'] = "root"; $bd['pswd'] = "root";
//Vues //Vues

@ -109,8 +109,7 @@ class ControleurVisiteur {
global $rep,$vues,$dataView; global $rep,$vues,$dataView;
$usrname=$_POST['login']; $usrname=$_POST['login'];
$pwd=$_POST['mdp']; $pwd=$_POST['mdp'];
Validation::clear_string($pwd); $vues_erreur=Validation::val_connexion($usrname,$pwd,$vues_erreur);
Validation::val_connexion($usrname,$pwd,$vues_erreur);
$model= new VisiteurModel(); $model= new VisiteurModel();
if($model->existUser($usrname)){ if($model->existUser($usrname)){
if(password_verify($pwd,$model->getHashedPassword($usrname))){ if(password_verify($pwd,$model->getHashedPassword($usrname))){
@ -147,6 +146,7 @@ class ControleurVisiteur {
public function creerListe(array $vues_erreur){ public function creerListe(array $vues_erreur){
global $rep, $vues; global $rep, $vues;
$nom=$_POST['name']; $nom=$_POST['name'];
$vues_erreur=Validation::val_intitule($nom, $vues_erreur);
$model = new ListeModel(); $model = new ListeModel();
if(isset($_SESSION['login'])){ if(isset($_SESSION['login'])){
$private=$_POST['private']; $private=$_POST['private'];
@ -173,6 +173,7 @@ class ControleurVisiteur {
require($rep.$vues['creerTache']); require($rep.$vues['creerTache']);
$intitule = $_POST['intitule']; $intitule = $_POST['intitule'];
$vues_erreur=Validation::val_intitule($intitule, $vues_erreur);
$model = new ListeModel(); $model = new ListeModel();
$model->creerTache(); $model->creerTache();

Loading…
Cancel
Save