mirror of
https://gitlab.com/animath/si/plateforme-corres2math.git
synced 2025-01-05 23:42:21 +00:00
Design "Confirmer mail" & mini-corrections
This commit is contained in:
parent
90952ecb7c
commit
60939771f6
@ -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);
|
||||
}
|
||||
|
@ -106,6 +106,6 @@
|
||||
<?php
|
||||
if (isset($has_error) && $has_error) { ?>
|
||||
<div class="alert alert-danger">
|
||||
Erreur : <?= $error_message ?>
|
||||
<strong>Erreur :</strong> <?= $error_message ?>
|
||||
</div>
|
||||
<?php }
|
@ -90,6 +90,12 @@ if (isset($user) && !$has_error) {
|
||||
|
||||
</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">
|
||||
<input class="btn btn-primary btn-lg btn-block" name="register" type="submit" value="S'inscrire"/>
|
||||
</div>
|
||||
|
@ -46,8 +46,8 @@ if (!$has_error && (isset($my_account) || isset($new_password))) {
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label for="receive_animath_mails">J'accepte de recevoir des mails de la part d'Animath :</label>
|
||||
<input class="form-control" type="checkbox" id="receive_animath_mails" name="receive_animath_mails"
|
||||
<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"
|
||||
<?= $user->doReceiveAnimathMails() ? "checked" : "" ?> />
|
||||
</div>
|
||||
|
||||
@ -62,12 +62,12 @@ if (!$has_error && (isset($my_account) || isset($new_password))) {
|
||||
<div class="form-group col-md-6">
|
||||
<label id="class_label" for="class">Classe :</label>
|
||||
<select id="class" name="class" class="custom-select">
|
||||
<option value="terminale"><?= SchoolClass::getTranslatedName(SchoolClass::TERMINALE) ?>
|
||||
<?= $user->getClass() == SchoolClass::TERMINALE ? "selected" : "" ?></option>
|
||||
<option value="premiere"><?= SchoolClass::getTranslatedName(SchoolClass::PREMIERE) ?>
|
||||
<?= $user->getClass() == SchoolClass::PREMIERE ? "selected" : "" ?></option>
|
||||
<option value="seconde"><?= SchoolClass::getTranslatedName(SchoolClass::SECONDE) ?>
|
||||
<?= $user->getClass() == SchoolClass::SECONDE ? "selected" : "" ?></option>
|
||||
<option value="terminale" <?= $user->getClass() == SchoolClass::TERMINALE ? "selected" : "" ?>>
|
||||
<?= SchoolClass::getTranslatedName(SchoolClass::TERMINALE) ?></option>
|
||||
<option value="premiere" <?= $user->getClass() == SchoolClass::PREMIERE ? "selected" : "" ?>>
|
||||
<?= SchoolClass::getTranslatedName(SchoolClass::PREMIERE) ?></option>
|
||||
<option value="seconde" <?= $user->getClass() == SchoolClass::SECONDE ? "selected" : "" ?>>
|
||||
<?= SchoolClass::getTranslatedName(SchoolClass::SECONDE) ?></option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user