Commit eb2154f1 authored by Kylian ou Nathan's avatar Kylian ou Nathan
Browse files

Up

parent 72b1768e
......@@ -45,7 +45,7 @@ class API extends CI_Controller{
$mail_send = $this->LogEmailModele->getAllDay();
if($mail_send != false AND !in_array($email_type, array_column($mail_send["raw"], "type"))){
if($mail_send == false OR !in_array($email_type, array_column($mail_send["raw"], "type"))){
$this->send_email($email_type);
}
......
......@@ -22,15 +22,27 @@ class Accueil extends CI_Controller
exit();
}
$data = $this->AccueilModele->get();
if ($this->input->server('REQUEST_METHOD') == 'POST') {
} else {
$data = $this->AccueilModele->get();
$data->capteur_log = $this->LogCapteurModele->getIntrusionForToday();
$data->capteur_log = $this->LogCapteurModele->getIntrusionForToday();
if( $data->capteur_log != false ) {
$data->capteur_log->date = DateTime::createFromFormat("Y-m-d H:i:s", $data->capteur_log->date);
}
// LISTER LES PROFILS EXISTANT
// CONNAITRE LE PROFIL ACTUEL
// ETAT DES CAPTEURS
$this->load->view('accueil/accueil', $data);
if( $data->capteur_log != false ) {
$data->capteur_log->date = DateTime::createFromFormat("Y-m-d H:i:s", $data->capteur_log->date);
}
$this->load->view('accueil/accueil', $data);
}
public function edit()
......
......@@ -114,7 +114,7 @@ class Authentification extends CI_Controller {
if($mdpoublie == true){
$this->send_email();
$this->send_email(uniqid());
$msg = array("envoye" => true);
$this->load->view('auth/mot_de_passe_oublie', $msg);
......@@ -134,7 +134,7 @@ class Authentification extends CI_Controller {
}
}
private function send_email(){
private function send_email($token){
$users = $this->AuthentificationModele->users_accepting_notification();
......@@ -144,7 +144,8 @@ class Authentification extends CI_Controller {
$to = implode(",", $users_email);
$subject = "[LOCKHOME] Demande de changement de mot de passe.";
$message = file_get_contents("./application/email/mot_passe_oublie.html");
$message = str_replace('$$_TOKEN_$$', $token, $message);
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: lockhome@lockhome.nrocher.fr' . "\r\n";
......@@ -160,9 +161,9 @@ class Authentification extends CI_Controller {
public function nouveau_mot_de_passe()
{
if(isset($_POST["email"] && isset($_POST["password"]))
if(isset($_POST["email"]) && isset($_POST["password"]))
{
$this->AuthentificationModele->new_mot_de_passe($_POST["password"], $_POST["email"]);
$this->AuthentificationModele->nouveau_mot_de_passe($_POST["password"], $_POST["email"]);
}
}
}
\ No newline at end of file
......@@ -362,7 +362,7 @@
<p>Vous avez demander une réinitialisation de mot de passe.</p>
<p>Veuillez cliquer sur le lien suivant pour réinitialiser votre mot de passe.</p>
<p>
<a href="https://lockhome.nrocher.fr/nouveau_mot_de_passe"></a>
<a href="https://lockhome.nrocher.fr/nouveau_mot_de_passe/$$_TOKEN_$$"></a>
</p>
</td>
</tr>
......
......@@ -74,7 +74,7 @@ class AuthentificationModele extends CI_Model
}
//METHODE PERMETTANT LE CHANGEMENT DE MOT DE PASSE
public function new_mot_de_passe($password, $email)
public function nouveau_mot_de_passe($password, $email)
{
$password = password_hash($password, PASSWORD_DEFAULT);
......
<?php
class MotDePasseOublieModele extends CI_Model
{
public function __construct()
{
$this->load->database();
}
private function getIdUser()
{
if($this->session->hes_userdata("email"))
{
$email = $this->session->hes_userdata("email");
$sqlUser = "SELECT id FROM Authentification WHERE email = ?";
return $this->db->query($sql, array($email));
}
}
public function update($token)
{
if($this->getIdUser())
{
$id = $this->getIdUser();
$sql = "UPDATE MotDePasseOublie SET token = ? WHERE id = ?";
$query = $this->db->query($sql, array($token, $id));
return $this->db->affected_rows();
}
}
public function delete($token)
{
if($this->getIdUser())
{
$id = $this->getIdUser();
$sql = "DELETE FROM MotDePasseOublie WHERE id = ?";
$query = $this->db->query($sql, array($id));
return $this->db->affected_rows();
}
}
public function add($token)
{
if($this->getIdUser())
{
$id = $this->getIdUser();
$sql = "INSERT INTO MotDePasseOublie VALUES (?, ?)";
$query = $this->db->query($sql, array($id, $token));
return $this->db->affected_rows();
}
}
}
?>
\ No newline at end of file
......@@ -18,7 +18,6 @@
<h2>Changement de mot de passe</h2>
<form action="./nouveau_mot_de_passe" method="post">
<input type="email" name="email" placeholder="Email" required="required">
<input type="password" name="mot_de_passe" placeholder="Mot de passe" required="required">
<button type="submit">Mettre à jour</button>
</form>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment