Envoie email à la connexion du compte (désactivé pour le moment)

pull/24/head
Leni BEAULATON 3 months ago
parent ad306dce2a
commit cf61ee55ba

@ -13,8 +13,8 @@ $login = '';
$mdp = ''; $mdp = '';
//$racine='/~kemondejar/WF-Website'; // /~kekentin/WF/WF-Website /~lebeaulato/WF-Website $racine='/~lebeaulato/WF-Website'; // /~kekentin/WF/WF-Website /~lebeaulato/WF-Website /~kemondejar/WF-Website
$racine='/WF-Website'; //$racine='/WF-Website';

@ -15,8 +15,8 @@ if(!isset($_SESSION['theme'])){
require_once __DIR__ . '/config/config.php'; require_once __DIR__ . '/config/config.php';
require __DIR__ . '/vendor/autoload.php'; require __DIR__ . '/vendor/autoload.php';
$co = new \Gateway\Connection('pgsql:host=localhost;dbname=wikifantasy3;', 'postgres', 'postgres'); //$co = new \Gateway\Connection('pgsql:host=localhost;dbname=wikifantasy3;', 'postgres', 'postgres');
//$co = new \Gateway\Connection('pgsql:host=localhost;dbname=dbkekentin;', 'kekentin', 'passwd'); $co = new \Gateway\Connection('pgsql:host=localhost;dbname=dbkekentin;', 'kekentin', 'passwd');
//twig //twig
$loader = new \Twig\Loader\FilesystemLoader('vue/templates'); $loader = new \Twig\Loader\FilesystemLoader('vue/templates');

@ -131,6 +131,7 @@ Class VisitorControler {
{ {
$_SESSION['user'] = Verification::verifChar($pseudo); $_SESSION['user'] = Verification::verifChar($pseudo);
$_SESSION['role'] = 'user'; $_SESSION['role'] = 'user';
//$this->sendEmailLogin($pseudo,$this->uMod->getEmailWithUser($pseudo)); Envoie un email pour chaque connexion
header("Location: ". $racine); header("Location: ". $racine);
exit(); exit();
}else }else
@ -195,7 +196,7 @@ Class VisitorControler {
exit(); exit();
} }
else echo $this->uMod->insertUser($pseudo, $email, $hmdp); else echo $this->uMod->insertUser($pseudo, $email, $hmdp);
$this->sendEmail($pseudo,$email); $this->sendEmailSignin($pseudo,$email);
$_SESSION["role"] = Verification::verifChar('user'); $_SESSION["role"] = Verification::verifChar('user');
$_SESSION["user"] = Verification::verifChar($pseudo); $_SESSION["user"] = Verification::verifChar($pseudo);
@ -204,7 +205,7 @@ Class VisitorControler {
} }
} }
public function sendEmail(string $pseudo, string $email) : void{ public function sendEmailSignin(string $pseudo, string $email) : void{
$to = $email; // Adresse email de destination $to = $email; // Adresse email de destination
$subject = "What The Fantasy - Création de compte"; // Sujet de l'email $subject = "What The Fantasy - Création de compte"; // Sujet de l'email
$message = " $message = "
@ -219,6 +220,22 @@ Class VisitorControler {
// Envoyer l'email // Envoyer l'email
mail($to, $subject, $message, $headers); mail($to, $subject, $message, $headers);
}
public function sendEmailLogin(string $pseudo, string $email) : void{
$to = $email; // Adresse email de destination
$subject = "What The Fantasy - Connexion à votre compte"; // Sujet de l'email
$message = "
Bonjour $pseudo,
Nous avons détecté une connexion à votre compte $pseudo. Si cela vient de vous, vous pouvez ignorer ce message. Sinon, nous vous conseillons de changer votre mot de passe.
L'équipe du site
"; // Contenu de l'email
$headers = "From: noreply@whatTheFantasy.com"; // Adresse email de l'expéditeur
// Envoyer l'email
mail($to, $subject, $message, $headers);
} }
} }

@ -200,5 +200,11 @@ Class UserGateway extends Gateway{
$query = 'UPDATE Users SET password=:newPassWd WHERE username=:username'; $query = 'UPDATE Users SET password=:newPassWd WHERE username=:username';
$this->co->executeQuery($query, array(':username'=>array($username, PDO::PARAM_STR), ':newPassWd'=> array($newPassWd, PDO::PARAM_STR))); $this->co->executeQuery($query, array(':username'=>array($username, PDO::PARAM_STR), ':newPassWd'=> array($newPassWd, PDO::PARAM_STR)));
} }
public function emailWithUser(string $user):array{
$query = 'SELECT email FROM Users WHERE username = :user';
$this->co->executeQuery($query, array(':user'=>array($user, PDO::PARAM_STR)));
return $this->co->getResults();
}
} }
?> ?>

@ -85,6 +85,11 @@
return $res[0]['id_user']; return $res[0]['id_user'];
} }
public function getEmailWithUser(string $user){
$res = $this->gateway->emailWithUser($user);
return $res[0]['email'];
}
// ===================== Bool FUNCTION ===================== // ===================== Bool FUNCTION =====================
public function IsExisteUsername(string $username):bool{ public function IsExisteUsername(string $username):bool{

Loading…
Cancel
Save