mirror of
https://gitlab.com/animath/si/plateforme-corres2math.git
synced 2025-07-07 11:04:01 +02:00
Design "Confirmer mail" & mini-corrections
This commit is contained in:
@ -2,18 +2,24 @@
|
||||
|
||||
$token = $_GET["token"];
|
||||
|
||||
$has_error = false;
|
||||
|
||||
if (isset($token)) {
|
||||
$result = $DB->query("SELECT `email` FROM `users` WHERE `confirm_email` = '$token' AND `year` = '$YEAR';");
|
||||
if (($data = $result->fetch()) === FALSE)
|
||||
$error_message = "Le jeton est invalide. Votre compte est peut-être déjà validé ?";
|
||||
if (($data = $result->fetch()) === FALSE) {
|
||||
$has_error = true;
|
||||
$error_message = "Le jeton est invalide. Votre compte est peut-être déjà validé ?";
|
||||
}
|
||||
else {
|
||||
$DB->exec("UPDATE `users` SET `confirm_email` = NULL WHERE `confirm_email` = '$token';");
|
||||
$error_message = "Votre adresse mail a été validée ! Vous pouvez désormais vous connecter.";
|
||||
}
|
||||
}
|
||||
else {
|
||||
$has_error = true;
|
||||
$error_message = "Il n'y a pas de compte à valider !";
|
||||
}
|
||||
require_once "server_files/views/header.php";
|
||||
echo "<h2>$error_message</h2>";
|
||||
if (!$has_error)
|
||||
echo "<div class=\"alert alert-success\">$error_message</div>";
|
||||
require_once "server_files/views/footer.php";
|
||||
|
@ -23,6 +23,7 @@ class NewUser
|
||||
public $role;
|
||||
public $school;
|
||||
public $class;
|
||||
public $receive_animath_mails;
|
||||
|
||||
public $description;
|
||||
public $confirm_email_token;
|
||||
@ -33,6 +34,8 @@ class NewUser
|
||||
{
|
||||
foreach ($data as $key => $value)
|
||||
$this->$key = htmlspecialchars($value);
|
||||
|
||||
$this->receive_animath_mails = $this->receive_animath_mails ? 1 : 0;
|
||||
}
|
||||
|
||||
public function makeVerifications()
|
||||
@ -63,10 +66,10 @@ class NewUser
|
||||
if (!$DB->query("SELECT `id` FROM `users` WHERE `year` = $YEAR;")->fetch())
|
||||
$this->role = Role::ADMIN;
|
||||
|
||||
$req = $DB->prepare("INSERT INTO `users`(`email`, `pwd_hash`, `confirm_email`, `surname`, `first_name`, `school`, `class`, `role`, `description`, `year`)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?);");
|
||||
$req = $DB->prepare("INSERT INTO `users`(`email`, `pwd_hash`, `confirm_email`, `surname`, `first_name`, `school`, `class`, `role`, `description`, `receive_animath_mails`, `year`)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);");
|
||||
$req->execute([$this->email, password_hash($this->password, PASSWORD_BCRYPT), $this->confirm_email_token, $this->surname, $this->first_name,
|
||||
$this->school, SchoolClass::getName($this->class), Role::getName($this->role), $this->description, $YEAR]);
|
||||
$this->school, SchoolClass::getName($this->class), Role::getName($this->role), $this->description, $this->receive_animath_mails, $YEAR]);
|
||||
|
||||
Mailer::sendRegisterMail($this);
|
||||
}
|
||||
|
Reference in New Issue
Block a user