mirror of
https://gitlab.com/animath/si/plateforme-corres2math.git
synced 2025-06-25 03:40:28 +02:00
Sans utilisateur, le premier inscrit est administrateur
This commit is contained in:
@ -48,6 +48,7 @@ class NewUser
|
||||
ensure($this->surname != "", "Le nom de famille est obligatoire.");
|
||||
ensure($this->first_name != "", "Le prénom est obligatoire.");
|
||||
$this->role = Role::fromName(strtoupper($this->role));
|
||||
ensure($this->role == Role::PARTICIPANT || $this->role == Role::ENCADRANT, "Vous devez être participant ou encadrant.");
|
||||
|
||||
if ($this->role == Role::PARTICIPANT)
|
||||
$this->class = SchoolClass::fromName(strtoupper($this->class));
|
||||
@ -59,6 +60,9 @@ class NewUser
|
||||
{
|
||||
global $DB, $YEAR;
|
||||
|
||||
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->execute([$this->email, password_hash($this->password, PASSWORD_BCRYPT), $this->confirm_email_token, $this->surname, $this->first_name,
|
||||
|
Reference in New Issue
Block a user