Skip to content

Commit

Permalink
tyt
Browse files Browse the repository at this point in the history
  • Loading branch information
adriendelagneau committed Aug 5, 2021
1 parent ec94dc0 commit a7ea1d7
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
8 changes: 6 additions & 2 deletions app/Controllers/back/BackController.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,11 +263,15 @@ function updateUser( $userId,$userName, $userFirstname, $userAdress, $userPhone,
require "app/Views/back/tableauDeBordUser.php";
}

function updateMdpUser($ancienMdp,$nouveauMdp,$nouveauMdpConfirm){
function updateMdpUser($userId,$ancienMdp,$nouveauMdpCrypte,$nouveauMdpConfirmCrypte){

$isPasswordCorrect3 = password_verify($ancienMdp, $_SESSION["userPWD"]);
if ($isPasswordCorrect3 == true){
if (($isPasswordCorrect3 == true)){

$mdp = new \Project\Models\UserManager();
$newMdp = $mdp->updateMdpUser($userId,$nouveauMdpCrypte);


require "app/Views/back/tableauDeBordUser.php";
} else{
echo "mot de passe incorect";
Expand Down
9 changes: 3 additions & 6 deletions app/Models/UserManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,10 @@ public function updateUser($userId, $userName, $userFirstname, $userAdress, $use
]);
return $req;
}
public function updatePwdUser($pwdUserc){
public function updateMdpUser($userId,$nouveauMdpCrypte){
$bdd = $this->dbConnect();
$req = $bdd->prepare("UPDATE userz SET userPWD = :pwdUserc WHERE userId = :userId");//: remplace $ dans requete sql
$req->execute([
'userPWD' => $pwdUserc

]);
$req = $bdd->prepare("UPDATE userz SET userPWD = ? WHERE userId = ?");//: remplace $ dans requete sql
$req->execute(array($nouveauMdpCrypte, $_SESSION['userId']));
return $req;
}
}
4 changes: 2 additions & 2 deletions app/Views/back/changePwd.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
<label for="nouveauMdp">new Password: </label>
<input type="password" placeholder="nouveauMdp" name="nouveauMdp" id="nouveauMdp">

<label for="toto">new Password: </label>
<input type="password" placeholder="confirmer votre mot de passe " name="toto" id="toto">
<label for="nouveauMdpConfirm">new Password: </label>
<input type="password" placeholder="confirmer votre mot de passe " name="nouveauMdpConfirm" id="nouveauMdpConfirm">


<input type="submit" value="OK">
Expand Down
7 changes: 6 additions & 1 deletion indexAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,16 @@
$userId = $_SESSION["userId"];

$ancienMdp = $_POST['ancienMdp'];
// $ancienMdpCrypte = password_hash($ancienMdp , PASSWORD_DEFAULT);

$nouveauMdp = $_POST['nouveauMdp'];
$nouveauMdpCrypte = password_hash($nouveauMdp , PASSWORD_DEFAULT);

$nouveauMdpConfirm = $_POST['nouveauMdpConfirm'];
$nouveauMdpConfirmCrypte = password_hash($nouveauMdpConfirm, PASSWORD_DEFAULT);


$backController->updateMdpUser( $ancienMdp, $nouveauMdp, $nouveauMdpConfirm);
$backController->updateMdpUser( $userId, $ancienMdp, $nouveauMdpCrypte, $nouveauMdpConfirmCrypte);
}


Expand Down

0 comments on commit a7ea1d7

Please sign in to comment.