mirror of
https://github.com/ZeJMaN/LBCAlerte_ynh.git
synced 2025-06-07 13:05:30 +02:00
21 lines
786 B
PHP
21 lines
786 B
PHP
<?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;
|
|
}
|
|
} |