list-Gtw-Mdl
Anna BOUDOUL 2 years ago
parent 30f4fa92c9
commit cfcc627fd7

@ -6,13 +6,10 @@ class FrontController
private UserModel $ursMdl;
private $action_User;
function __construct($ursMdl=new UserModel(), $action_User=[]){
$this->$ursMdl = $ursMdl;
$this->$action_User = $action_User;
function __construct(){
session_start();
}
$ursMdl = new UserModel();
function handleAction(){
try{
$user = $this->usrMdl.isUser(); // cette fonction retourne quoi?
$action = $_GET['action'];

@ -1,47 +1,49 @@
<?php
require('../dal/UserGateway.php');
require('../model/UserModel.php');
class CtrlUser
{
private $model;
private $view;
private $con;
public function __construct(TaskModel $model, HomeView $view,
Connection $con){
session_start();
$this->model = $model;
$this->view = $view;
public function __construct(Connection $con){
$this->model = new UserModel();
$this->con = $con;
}
public function handleAction(){
try{
$action=$_REQUEST['action'];
switch($action){
// pas d'action afficher la home page avec toutes les listes
case NULL:
$this->home();
break;
// case NULL:
// $this->home();
// break;
// ajouter une liste publique
case 'creer_liste_pub':
$this->newList('private');
// voir les listes privees
case 'voir_liste_priv':
$this->listepriv();
break;
// ajouter une liste privee
case 'creer_liste_priv':
$this->newList('public');
break;
// supprimer une liste
case 'supprimer_liste':
$this->delList();
break;
// changer nom de la liste
case 'changer_nom':
$this->changeListName();
break;
// // ajouter une liste publique
// case 'creer_liste_pub':
// $this->newList('public');
// break;
// // ajouter une liste privee
// case 'creer_liste_priv':
// $this->newList('private');
// break;
// // supprimer une liste
// case 'supprimer_liste':
// $this->delList();
// break;
// // changer nom de la liste
// case 'changer_nom':
// $this->changeListName();
// break;
// ajouter une tache

@ -44,12 +44,11 @@
}
public function findUser($login, $mdp){
$pwrd = password_hash($mdp, PASSWORD_BCRYPT, array("cost" => 12));
$query = 'SELECT login FROM User WHERE login = :login AND mdp = :mdp';
$this->con->executeQuery($query, array(':login'=>array($login, PDO::PARAM_STR),
':mdp'=>array($pwrd, PDO::PARAM_STR)));
$query = 'SELECT mdp FROM User WHERE login = :login';
$this->con->executeQuery($query, array(':login'=>array($login, PDO::PARAM_STR)));
$result = $this->con->getResults();
return $result;
if(password_verify($mdp, $result[0]['mdp']))
return $login;
}
}
?>

@ -6,11 +6,16 @@
public function __construct(Connection $con) {
$this->con = $con;
$this->gat = new GatUser($con); }
$this->gat = new UserGateway($con);
}
function connexion($login, $mdp){
$gat->findUser($login, $mdp);
$_SESSION['login'] = $login;
$result = $this->gat->findUser($login, $mdp);
if (isset($result))
{
$_SESSION['login'] = $result;
}
echo $_SESSION['login'];
}
function deconnexion(){
@ -20,7 +25,7 @@
}
function isConnected($login){ //teste rôle dans la session, retourne instance dobjet ou booleen
if (isset($_SESSION['login']))
if ($_SESSION['login'])
{
return true;
}

@ -11,10 +11,10 @@ $t = new Task(5,'tacheNotErr','desc.','urgent','001');
# connection
include("credentials.php");
$con = new Connection('mysql:host=localhost;dbname=phpproject',$user,$pass);
$con = new Connection('mysql:host=localhost;dbname=dbanboudoul', 'anboudoul', 'achanger');
# gateway
$tgt = new TaskGateway($con);
// $tgt = new TaskGateway($con);
//$tgt->insert($t);
//$tgt->delete('10');
@ -24,16 +24,16 @@ foreach($tasks as $i)
echo $i->get_id()."<br>"; */
# Test du modele Tache
$mt= new TaskModel($con);
// $mt= new TaskModel($con);
//$mt->addTask('3','testIsDone','desc.','urgent','001');
//$mt->modifTask('3','isDone','1');
//$tasks = $mt->getTaskBy('titre','tache1');
$tasks = $mt->getAllTask();
foreach($tasks as $i)
echo $i->get_id()."<br>";
// $tasks = $mt->getAllTask();
// foreach($tasks as $i)
// echo $i->get_id()."<br>";
$mt->addList('002','todo2','nifranco');
$mt->modifList('2','nom','22do');
// $mt->addList('002','todo2','nifranco');
// $mt->modifList('2','nom','22do');
//mt->supList('2');
/* -------------
@ -54,11 +54,12 @@ require('../model/UserModel.php');
// Test Modèle User
// $mdl = new UserModel($con);
$mdl = new UserModel($con);
// $mdl->ajouter('Anna', 'unmdptrescomplique');
// $mdl->modifLogin('Anna', 'Aeryn');
// $mdl->modifMdp('Aeryn', 'wtfmec');
// $mdl->supprimer('Aeryn');
$mdl->connexion('Aeryn', 'wtfmec');
?>

Loading…
Cancel
Save