mirror of
https://gitlab.com/animath/si/plateforme-corres2math.git
synced 2025-01-07 13:02:21 +00:00
Design "Confirmer mail" & mini-corrections
This commit is contained in:
parent
90952ecb7c
commit
60939771f6
@ -2,18 +2,24 @@
|
|||||||
|
|
||||||
$token = $_GET["token"];
|
$token = $_GET["token"];
|
||||||
|
|
||||||
|
$has_error = false;
|
||||||
|
|
||||||
if (isset($token)) {
|
if (isset($token)) {
|
||||||
$result = $DB->query("SELECT `email` FROM `users` WHERE `confirm_email` = '$token' AND `year` = '$YEAR';");
|
$result = $DB->query("SELECT `email` FROM `users` WHERE `confirm_email` = '$token' AND `year` = '$YEAR';");
|
||||||
if (($data = $result->fetch()) === FALSE)
|
if (($data = $result->fetch()) === FALSE) {
|
||||||
$error_message = "Le jeton est invalide. Votre compte est peut-être déjà validé ?";
|
$has_error = true;
|
||||||
|
$error_message = "Le jeton est invalide. Votre compte est peut-être déjà validé ?";
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
$DB->exec("UPDATE `users` SET `confirm_email` = NULL WHERE `confirm_email` = '$token';");
|
$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.";
|
$error_message = "Votre adresse mail a été validée ! Vous pouvez désormais vous connecter.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
$has_error = true;
|
||||||
$error_message = "Il n'y a pas de compte à valider !";
|
$error_message = "Il n'y a pas de compte à valider !";
|
||||||
}
|
}
|
||||||
require_once "server_files/views/header.php";
|
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";
|
require_once "server_files/views/footer.php";
|
||||||
|
@ -23,6 +23,7 @@ class NewUser
|
|||||||
public $role;
|
public $role;
|
||||||
public $school;
|
public $school;
|
||||||
public $class;
|
public $class;
|
||||||
|
public $receive_animath_mails;
|
||||||
|
|
||||||
public $description;
|
public $description;
|
||||||
public $confirm_email_token;
|
public $confirm_email_token;
|
||||||
@ -33,6 +34,8 @@ class NewUser
|
|||||||
{
|
{
|
||||||
foreach ($data as $key => $value)
|
foreach ($data as $key => $value)
|
||||||
$this->$key = htmlspecialchars($value);
|
$this->$key = htmlspecialchars($value);
|
||||||
|
|
||||||
|
$this->receive_animath_mails = $this->receive_animath_mails ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function makeVerifications()
|
public function makeVerifications()
|
||||||
@ -63,10 +66,10 @@ class NewUser
|
|||||||
if (!$DB->query("SELECT `id` FROM `users` WHERE `year` = $YEAR;")->fetch())
|
if (!$DB->query("SELECT `id` FROM `users` WHERE `year` = $YEAR;")->fetch())
|
||||||
$this->role = Role::ADMIN;
|
$this->role = Role::ADMIN;
|
||||||
|
|
||||||
$req = $DB->prepare("INSERT INTO `users`(`email`, `pwd_hash`, `confirm_email`, `surname`, `first_name`, `school`, `class`, `role`, `description`, `year`)
|
$req = $DB->prepare("INSERT INTO `users`(`email`, `pwd_hash`, `confirm_email`, `surname`, `first_name`, `school`, `class`, `role`, `description`, `receive_animath_mails`, `year`)
|
||||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?);");
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);");
|
||||||
$req->execute([$this->email, password_hash($this->password, PASSWORD_BCRYPT), $this->confirm_email_token, $this->surname, $this->first_name,
|
$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);
|
Mailer::sendRegisterMail($this);
|
||||||
}
|
}
|
||||||
|
@ -106,6 +106,6 @@
|
|||||||
<?php
|
<?php
|
||||||
if (isset($has_error) && $has_error) { ?>
|
if (isset($has_error) && $has_error) { ?>
|
||||||
<div class="alert alert-danger">
|
<div class="alert alert-danger">
|
||||||
Erreur : <?= $error_message ?>
|
<strong>Erreur :</strong> <?= $error_message ?>
|
||||||
</div>
|
</div>
|
||||||
<?php }
|
<?php }
|
@ -90,6 +90,12 @@ if (isset($user) && !$has_error) {
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="form-row">
|
||||||
|
<label for="receive_animath_mails">J'accepte de recevoir des mails de la part d'Animath (<em>facultatif</em>) :</label>
|
||||||
|
<input class="form-control" type="checkbox" id="receive_animath_mails" name="receive_animath_mails"
|
||||||
|
<?= isset($user) && $user->receive_animath_mails ? "checked" : "" ?> />
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<input class="btn btn-primary btn-lg btn-block" name="register" type="submit" value="S'inscrire"/>
|
<input class="btn btn-primary btn-lg btn-block" name="register" type="submit" value="S'inscrire"/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -46,8 +46,8 @@ if (!$has_error && (isset($my_account) || isset($new_password))) {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="receive_animath_mails">J'accepte de recevoir des mails de la part d'Animath :</label>
|
<label for="receive_animath_mails">J'accepte de recevoir des mails de la part d'Animath (<em>facultatif</em>) :</label>
|
||||||
<input class="form-control" type="checkbox" id="receive_animath_mails" name="receive_animath_mails"
|
<input class="form-control" type="checkbox" id="receive_animath_mails" name="receive_animath_mails"
|
||||||
<?= $user->doReceiveAnimathMails() ? "checked" : "" ?> />
|
<?= $user->doReceiveAnimathMails() ? "checked" : "" ?> />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -62,12 +62,12 @@ if (!$has_error && (isset($my_account) || isset($new_password))) {
|
|||||||
<div class="form-group col-md-6">
|
<div class="form-group col-md-6">
|
||||||
<label id="class_label" for="class">Classe :</label>
|
<label id="class_label" for="class">Classe :</label>
|
||||||
<select id="class" name="class" class="custom-select">
|
<select id="class" name="class" class="custom-select">
|
||||||
<option value="terminale"><?= SchoolClass::getTranslatedName(SchoolClass::TERMINALE) ?>
|
<option value="terminale" <?= $user->getClass() == SchoolClass::TERMINALE ? "selected" : "" ?>>
|
||||||
<?= $user->getClass() == SchoolClass::TERMINALE ? "selected" : "" ?></option>
|
<?= SchoolClass::getTranslatedName(SchoolClass::TERMINALE) ?></option>
|
||||||
<option value="premiere"><?= SchoolClass::getTranslatedName(SchoolClass::PREMIERE) ?>
|
<option value="premiere" <?= $user->getClass() == SchoolClass::PREMIERE ? "selected" : "" ?>>
|
||||||
<?= $user->getClass() == SchoolClass::PREMIERE ? "selected" : "" ?></option>
|
<?= SchoolClass::getTranslatedName(SchoolClass::PREMIERE) ?></option>
|
||||||
<option value="seconde"><?= SchoolClass::getTranslatedName(SchoolClass::SECONDE) ?>
|
<option value="seconde" <?= $user->getClass() == SchoolClass::SECONDE ? "selected" : "" ?>>
|
||||||
<?= $user->getClass() == SchoolClass::SECONDE ? "selected" : "" ?></option>
|
<?= SchoolClass::getTranslatedName(SchoolClass::SECONDE) ?></option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user