mirror of
https://github.com/ZeJMaN/LBCAlerte_ynh.git
synced 2025-07-19 09:50:49 +02:00
Initial commit
Functional, without SSO
This commit is contained in:
21
sources/app/admin/scripts/add-user.php
Normal file
21
sources/app/admin/scripts/add-user.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
$user = new \App\User\User();
|
||||
$errors = array();
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
if (!isset($_POST["username"]) || !trim($_POST["username"])) {
|
||||
$errors["username"] = "Veuillez indiquer un nom d'utilisateur.";
|
||||
} else {
|
||||
$user->setUsername(trim($_POST["username"]));
|
||||
}
|
||||
if (empty($_POST["password"])) {
|
||||
$errors["password"] = "Veuillez indiquer un mot de passe.";
|
||||
} elseif (empty($_POST["password"]) || $_POST["password"] != $_POST["confirmPassword"]) {
|
||||
$errors["confirmPassword"] = "Les deux mots de passe ne correspondent pas.";
|
||||
}
|
||||
if (empty($errors)) {
|
||||
$user->setPassword(sha1($_POST["password"]));
|
||||
$userStorage->save($user);
|
||||
header("LOCATION: ?mod=admin&a=users");
|
||||
exit;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user