From 451f8aec79f58d67eb8a9d6097c39c99d26f8b09 Mon Sep 17 00:00:00 2001 From: viastolfi Date: Wed, 7 Dec 2022 15:25:41 +0100 Subject: [PATCH] ajout API : recuperer le mot de passe d'un user depuis son mail --- Sources/API/api/inscrit/readMdpFromMail.php | 30 +++++++++++++++++++++ Sources/API/models/Inscrit.php | 14 ++++++++++ 2 files changed, 44 insertions(+) create mode 100644 Sources/API/api/inscrit/readMdpFromMail.php diff --git a/Sources/API/api/inscrit/readMdpFromMail.php b/Sources/API/api/inscrit/readMdpFromMail.php new file mode 100644 index 0000000..e42738c --- /dev/null +++ b/Sources/API/api/inscrit/readMdpFromMail.php @@ -0,0 +1,30 @@ +connect(); + $inscrit = new Inscrit($db); + + $results = $inscrit->readMdpFromMail($_GET['mail']); + $num = $results->rowCount(); + + if($num > 0){ + $inscrit_array = array(); + + while($row = $results->fetch(PDO::FETCH_ASSOC)){ + extract($row); + + $inscrit_item = array( + 'mdp' => $mdp + ); + array_push($inscrit_array, $inscrit_item); + } + echo json_encode($inscrit_array); + } else { + echo json_encode(array('message' => 'No Inscrit with mail='.$_GET['mail'])); + } +?> \ No newline at end of file diff --git a/Sources/API/models/Inscrit.php b/Sources/API/models/Inscrit.php index b55d9ed..02698ef 100644 --- a/Sources/API/models/Inscrit.php +++ b/Sources/API/models/Inscrit.php @@ -30,6 +30,20 @@ $stmt->execute(); return $stmt; } + + public function readMdpFromMail($mail){ + $query = 'SELECT + i.mdp as mdp + FROM + '.$this->table.' i + WHERE + i.mail=:mail + '; + $stmt = $this->conn->prepare($query); + $stmt->bindValue(':mail',$mail, PDO::PARAM_STR); + $stmt->execute(); + return $stmt; + } } ?> \ No newline at end of file