Mathilde JEAN 2 years ago
commit d7e13c70a6

@ -8,34 +8,30 @@ class UserController{
session_sart(); session_sart();
$arrayErrorViews= array(); $arrayErrorViews= array();
try{ $action = $_REQUEST['action']??null;
$action = $_REQUEST['action']??null; switch($action){
switch($action){ case "deconnection":
case "deconnection": $this->deconnection($arrayErrorViews);
$this->deconnection($arrayErrorViews); break;
break; case "creerListePv":
case "creerListePv": $this->creerListe($arrayErrorViews);
$this->creerListe($arrayErrorViews); break;
break; case "desinscription":
case "desinscription": $this->desinctription($arrayErrorViews);
$this->desinctription($arrayErrorViews); break;
break; case "changerInfos":
case "changerInfos": $this->changerPassword($arrayErrorViews);
$this->changerInfos($arrayErrorViews); break;
break; default :
default : $arrayErrorViews[]="Erreur innatendue !!!";
$arrayErrorViews[]="Erreur innatendue !!!"; require($rep.$vues['error']);
require($rep.$vues['error']);
}
}catch(PDOException $e){
$dataView[]="Erreur inatendue";
require($rep.$vues['erreur']);
} }
} }
public function deconnection($arrayErrorViews){ public function deconnection($arrayErrorViews){
// appeler la méthode deco du modèle // appeler la méthode deco du modèle
UserModel::deconnection(); $retour = UserModel::deconnection();
require($rep.$vues['acceuil']);
} }
public function creerListePv($arrayErrorViews){ public function creerListePv($arrayErrorViews){
@ -50,22 +46,35 @@ class UserController{
//Validation::clear_string($_POST['ListName']); //Validation::clear_string($_POST['ListName']);
// appelle à la methode du modèle // appelle à la methode du modèle
if($privee == true){ if($privee == true){
UserModel::creerListePv($nomListe,$_SESSION['login']); try{
UserModel::creerListePv($nomListe,$_SESSION['login']);
} catch (PDOException $e){
$dataView[]="Erreur inatendue";
require($rep.$vues['erreur']);
}
}else{ }else{
VisitorModel::creerListe($nomListe); try{
VisitorModel::creerListe($nomListe);
} catch (PDOException $e){
$dataView[]="Erreur inatendue";
require($rep.$vues['erreur']);
}
} }
} }
public function desinscription($arrayErrorViews){ public function changerPassword($arrayErrorViews){
global $rep, $vues; global $rep, $vues;
// recup valeurs des champs $password1=$_POST['password1'];
$password=$_POST['password']; $passwordConfirm=$_POST['passwordConfirm'];
// valider les champs $newPassword=Validation::val_changer_password($password1,$passwordConfirm);
Validation::val_desinscription($password);
// vider les champs try{
//Validation::clear_string($_POST['password']); UserModel::changerPassword($newPassword);
// appel à la classe userModel require($rep.$vues['profil'])
UserModel::desinscription($_SESSION['login']); }catch(PDOException $e){
$dataView[]="Erreur inatendue";
require($rep.$vues['erreur']);
}
} }
} }

@ -23,6 +23,10 @@ class UserModel{
public function desinscription($login){ public function desinscription($login){
$this->usergw->delUtilisateur($login); $this->usergw->delUtilisateur($login);
} }
public function changerPassword($newPassword){
$this->usergw->putPassword($newPassword);
}
} }
?> ?>
Loading…
Cancel
Save