2022-05-22 14:59:45 +02:00
|
|
|
<?php require "../../common/html.php"; ?>
|
2021-01-22 21:58:46 +01:00
|
|
|
|
2021-02-17 22:48:49 +01:00
|
|
|
<form method="post">
|
2022-04-18 16:05:00 +02:00
|
|
|
<label for="username">Identifiant</label><br>
|
|
|
|
<input required="" minlength="4" maxlength="32" pattern="<?= USERNAME_REGEX ?>" id="username" name="username" type="text" placeholder="lain">
|
|
|
|
<br>
|
2021-01-22 21:58:46 +01:00
|
|
|
|
2022-04-18 16:05:00 +02:00
|
|
|
<label for="password">Clé de passe</label><br>
|
|
|
|
<input required="" autocomplete="current-password" minlength="8" maxlength="1024" pattern="<?= PASSWORD_REGEX ?>" id="password" name="password" type="password" placeholder="************************">
|
|
|
|
<br>
|
2021-01-22 21:58:46 +01:00
|
|
|
|
2022-04-18 16:05:00 +02:00
|
|
|
<input type="submit">
|
2021-02-17 22:48:49 +01:00
|
|
|
</form>
|
2021-01-22 21:58:46 +01:00
|
|
|
|
2021-02-17 22:48:49 +01:00
|
|
|
Pas de compte ? <a class="authButton" href="register">En créer un</a>
|
2021-01-25 13:39:31 +01:00
|
|
|
|
2021-02-17 22:48:49 +01:00
|
|
|
<?php
|
2021-01-22 21:58:46 +01:00
|
|
|
|
2021-02-17 22:48:49 +01:00
|
|
|
if (isset($_POST['username']) AND isset($_POST['password'])) {
|
2021-01-22 21:58:46 +01:00
|
|
|
|
2022-04-18 16:05:00 +02:00
|
|
|
antiCSRF();
|
2021-08-05 14:04:33 +02:00
|
|
|
|
2022-05-20 02:19:45 +02:00
|
|
|
checkPasswordFormat($_POST['password']);
|
2021-01-22 21:58:46 +01:00
|
|
|
|
2022-05-20 02:19:45 +02:00
|
|
|
checkUsernameFormat($_POST['username']);
|
2021-01-22 21:58:46 +01:00
|
|
|
|
2022-05-22 14:59:45 +02:00
|
|
|
if (userExist($_POST['username']) !== true)
|
|
|
|
userError("Connexion impossible : ce compte n'existe pas.");
|
2021-08-05 02:51:21 +02:00
|
|
|
|
2022-05-22 14:59:45 +02:00
|
|
|
if (checkPassword($_POST['username'], $_POST['password']) !== true)
|
|
|
|
userError("Connexion impossible : clé de passe invalide.");
|
2021-08-05 02:51:21 +02:00
|
|
|
|
2022-05-22 14:59:45 +02:00
|
|
|
$_SESSION['username'] = $_POST['username'];
|
2021-08-05 02:51:21 +02:00
|
|
|
|
2022-05-22 14:59:45 +02:00
|
|
|
if (outdatedPasswordHash($_SESSION['username']))
|
|
|
|
changePassword($_SESSION['username'], $_POST['password']);
|
|
|
|
|
|
|
|
if (isset($_GET['redir'])) {
|
|
|
|
if (preg_match("/^[0-9a-z\/-]+$/", $_GET['redir']) !== 1)
|
|
|
|
userError("Wrong character in <code>redir</code>.");
|
|
|
|
header("Location: " . CONF['common']['prefix'] . "/" . $_GET['redir']);
|
2022-04-18 16:05:00 +02:00
|
|
|
} else {
|
2022-05-22 14:59:45 +02:00
|
|
|
header("Location: " . CONF['common']['prefix'] . "/");
|
2022-04-18 16:05:00 +02:00
|
|
|
}
|
2021-02-17 22:48:49 +01:00
|
|
|
}
|
2021-01-22 21:58:46 +01:00
|
|
|
|
2021-02-17 22:48:49 +01:00
|
|
|
?>
|
2021-01-22 21:58:46 +01:00
|
|
|
|
2022-05-22 14:59:45 +02:00
|
|
|
<?php closeHTML(); ?>
|