ajout API : recuperer le mot de passe d'un user depuis son mail
continuous-integration/drone/push Build is failing Details

API
Vincent ASTOLFI 2 years ago
parent c9db235c3b
commit 451f8aec79

@ -0,0 +1,30 @@
<?php
header('Acces-Control-Allow-Origin: *');
header('Content-Type: application/json');
include_once '../../config/Database.php';
include_once '../../models/Inscrit.php';
$database = new Database();
$db = $database->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']));
}
?>

@ -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;
}
}
?>
Loading…
Cancel
Save