Skip to content

Commit

Permalink
tyt
Browse files Browse the repository at this point in the history
  • Loading branch information
adriendelagneau committed Aug 2, 2021
1 parent c801074 commit 9c8ff37
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 5 deletions.
13 changes: 13 additions & 0 deletions app/Controllers/back/BackController.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,5 +263,18 @@ function updateUser( $userId,$userName, $userFirstname, $userAdress, $userPhone,

require "app/Views/back/tableauDeBordUser.php";
}
function updatePwdUser( $pwdUser, $pwdUserc, $pwdUsercc){
$user = new \Project\Models\UserManager();
$isPasswordCorrect3 = password_verify($pwdUser, $_SESSION["userPWD"]);
if (($isPasswordCorrect2) && ($pwdUserc == $pwdUsercc)){
$updateUser = $user->updateUser( $pwdUsercc);



require "app/Views/back/tableauDeBordUser.php";
}else{
echo "new error";
}

}
}
11 changes: 8 additions & 3 deletions app/Controllers/front/FrontController.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,14 @@ function inscription($userName, $userFirstname, $userAdress, $userPhone, $userM
$inscription = $toto->newUser($userName, $userFirstname, $userAdress, $userPhone, $userMail, $userPWD);


$aLaUne = new \Project\Models\ImagesManager();
$allALaUne = $aLaUne->getALaUne();
require "app/Views/back/tableauDeBordUser.php";
$slides = new \Project\Models\ImagesManager();
$allSlides = $slides->getSlides();
$aLaUne = new \Project\Models\ImagesManager();
$allALaUne = $aLaUne->getALaUne();
$reducs = new \Project\Models\ReducManager();
$allReducs = $reducs->allReducs();
require "app/Views/front/accueil.php";

echo '<script>alert("Bravo, vous etes maintenant inscrit");</script>';
}
} else{
Expand Down
9 changes: 9 additions & 0 deletions app/Models/UserManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ public function updateUser($userId, $userName, $userFirstname, $userAdress, $use
'userPhone' => $userPhone,
'userMail' => $userMail

]);
return $req;
}
public function updatePwdUser($pwdUserf){
$bdd = $this->dbConnect();
$req = $bdd->prepare("UPDATE userz SET userPWD = :pwdUserf WHERE userId = :userId");//: remplace $ dans requete sql
$req->execute([
'userPWD' => $pwdUserf

]);
return $req;
}
Expand Down
16 changes: 16 additions & 0 deletions app/Views/back/changePwd.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@

<?php echo $_SESSION['userPWD']?>

<form action="index.php?action=changementMdpUser" method="post">

<label for="pwdUser">password : </label>
<input type="text" placeholder="pwdUser" name="pwdUser" id="pwdUser">

<label for="pwdUserc">new Password: </label>
<input type="password" placeholder="pwdUserc" name="pwdUserc" id="pwdUserc">

<label for="pwdUsercc">new Password: </label>
<input type="password" placeholder="pwdUsercc" name="pwdUsercc" id="pwdUsercc">

<input type="submit" value="OK">
<!-- <p action ="index.php?action=deconnexionUser">deconnexion user</p> -->
</form>


<?php $content = ob_get_clean()?>
<?php require 'templates/templateUser.php'?>

2 changes: 1 addition & 1 deletion app/Views/back/orderList.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
<h1> Liste des commandes</h1>

<?php $content = ob_get_clean()?>
<?php require 'templates/template.php'?>
<?php require 'templates/templateUser.php'?>

17 changes: 16 additions & 1 deletion indexAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
$backController->tdbProducts();
}
else if($_GET["action"] == "tableauDeBordUser"){

$backController->tableauDeBordUser();
}
else if($_GET["action"] == "deconnexion"){
$backController->deconnexion();
Expand Down Expand Up @@ -201,6 +201,21 @@
}


elseif($_GET["action"] == "changementMdpUser"){
$pwdUser = $_POST['pwdUser'];
$pwdUserc = $_POST['pwdUserc'];
$pwdUsercc = $_POST['pwdUsercc'];
$user1 = htmlspecialchars($_POST["userPWD"]);
$userPWD = password_hash($user1, PASSWORD_DEFAULT);
if(($pwdUser == $_SESSION['userPWD']) && ($pwdUserc == $pwdUsercc )){
$pwdUserf = password_hash($pwdUsercc, PASSWORD_DEFAULT);
$backController->updatePwdUser( $pwdUserf);
}else{
throw new Exception("renseignez tout les champs s.v.p");
}
}



}else{
$backController->tableauDeBord();
Expand Down

0 comments on commit 9c8ff37

Please sign in to comment.