main
thchazot1 2 years ago
parent 422843a815
commit 5db7846794

@ -90,21 +90,19 @@ class VisitorController {
$this->reinit(); $this->reinit();
} }
public function Connexion(array $dVueEreur){ public function Connection(array $dVueEreur){
global $rep,$vues,$dataView; global $rep,$vues,$dataView;
$username=$_POST['login']; $username=$_POST['username'];
$password=$_POST['mdp']; $password=$_POST['password'];
$dVueEreur=Validation::val_connexion($username,$password,$dVueEreur); $dVueEreur=Validation::val_connexion($username,$password,$dVueEreur);
if(!empty($dVueEreur)){ if(!empty($dVueEreur)){
require($rep.$vues['signIn']); require($rep.$vues['signIn']);
} }
$model= new MdlUser(); $model= new MdlUser();
$model->insert("wesh", "wesh");
if($model->existUser($username)){ if($model->existUser($username)){
echo $model->getPasswordHash($username);
if(password_verify($password,$model->getPasswordHash($username))){ if(password_verify($password,$model->getPasswordHash($username))){
echo "wesh";
$model->connexion($username); $model->connexion($username);
$_REQUEST['action']=null; $_REQUEST['action']=null;
$this->reinit(); $this->reinit();
@ -116,7 +114,7 @@ class VisitorController {
} }
} }
else{ else{
$dVueEreur =array('username'=>$usrname,'password'=>$pwd); $dVueEreur =array('username'=>$username,'password'=>$password);
require($rep.$vues['signIn']); require($rep.$vues['signIn']);
} }
} }

@ -92,18 +92,7 @@ class ListeGateway
} }
$listes[] = new Liste($row['id'], $row['name'],false, null, $taches); $listes[] = new Liste($row['id'], $row['name'],false, null, $taches);
$taches = array(); $taches = array();
<<<<<<< HEAD
/*$queryBug = "SELECT count(*) FROM Liste WHERE idCreator IS NULL";
$this->con->executeQuery($queryBug, array(':idListe' => array($idListe, PDO::PARAM_INT)));
$resultsBug = $this->con->getResults();
echo "$resultsBug[0][0]";
if (sizeof($listes)===$resultsBug[0][0]){
break;
}
*/
=======
>>>>>>> cd1b36dfd8a0767bdf2fe5ed8a1c4626e0921507
} }
} }

@ -9,10 +9,10 @@ class UserGateway
$this->con = $con; $this->con = $con;
} }
public function insert(User $u){ public function insert($login, $mdp){
try{ try{
$query = "INSERT INTO Utilisateur VALUES (null, :username, PASSWORD(:password))"; $query = "INSERT INTO Utilisateur VALUES (null, :username, :password)";
$this->con->executeQuery($query, array(':username' => array($u->getUsername(), PDO::PARAM_STR), ':password' => array($u->getPassword(), PDO::PARAM_STR))); $this->con->executeQuery($query, array(':username' => array($login, PDO::PARAM_STR), ':password' => array($mdp, PDO::PARAM_STR)));
} }
catch(PDOException $Exception){ catch(PDOException $Exception){
echo 'erreur'; echo 'erreur';
@ -51,9 +51,9 @@ class UserGateway
function getHashedPassword(string $usrname):?string{ function getHashedPassword(string $usrname):?string{
$truePasswd=null; $truePasswd=null;
$query="SELECT PASSWORD(`password`) FROM Utilisateur WHERE username=:username"; $query="SELECT password FROM Utilisateur WHERE username=:username";
$this->con->executeQuery($query,array('username'=>array($usrname,PDO::PARAM_STR))); $this->con->executeQuery($query,array('username'=>array($usrname,PDO::PARAM_STR)));
$results=$co->getResults(); $results=$this->con->getResults();
foreach($results as $row){ foreach($results as $row){
$truePasswd=$row['password']; $truePasswd=$row['password'];
} }

@ -17,10 +17,12 @@ class MdlUser{
} }
public function signUp($login, $mdp){ public function signUp($login, $mdp){
$result=$this->con->insert($login, $mdp); $gate=new UserGateway($this->con);
$result=$gate->insert($login, $mdp);
if ($result==true){ if ($result==true){
$_SESSION['role'] = 'Utilisateur'; $_SESSION['role'] = 'Utilisateur';
$_SESSION['login'] = $login; $_SESSION['username'] = $login;
} }
} }

Loading…
Cancel
Save