2022-09-01 04:21:17 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
if (processForm(false)) {
|
|
|
|
checkPasswordFormat($_POST['password']);
|
|
|
|
|
|
|
|
checkUsernameFormat($_POST['username']);
|
|
|
|
|
2022-11-30 23:12:42 +01:00
|
|
|
$username = hashUsername($_POST['username']);
|
2022-11-26 21:45:48 +01:00
|
|
|
|
2022-11-30 23:12:42 +01:00
|
|
|
if (usernameExists($username) !== true)
|
2022-09-15 19:17:48 +02:00
|
|
|
output(403, 'Connexion impossible : ce compte n\'existe pas.');
|
2022-09-01 04:21:17 +02:00
|
|
|
|
2022-11-30 23:12:42 +01:00
|
|
|
$id = query('select', 'users', ['username' => $username], 'id')[0];
|
|
|
|
|
|
|
|
if (checkPassword($id, $_POST['password']) !== true)
|
2022-09-15 19:17:48 +02:00
|
|
|
output(403, 'Connexion impossible : clé de passe invalide.');
|
2022-09-01 04:21:17 +02:00
|
|
|
|
2022-11-30 23:12:42 +01:00
|
|
|
$_SESSION['id'] = $id;
|
2022-11-26 21:45:48 +01:00
|
|
|
$_SESSION['display-username'] = htmlspecialchars($_POST['username']);
|
2022-11-30 23:12:42 +01:00
|
|
|
$_SESSION['type'] = query('select', 'users', ['id' => $id], 'type')[0];
|
2022-09-01 04:21:17 +02:00
|
|
|
|
2022-11-30 23:12:42 +01:00
|
|
|
if (outdatedPasswordHash($id))
|
|
|
|
changePassword($id, $_POST['password']);
|
2022-09-01 04:21:17 +02:00
|
|
|
|
|
|
|
redir();
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|
2021-01-22 21:58:46 +01:00
|
|
|
|
2022-06-06 23:14:50 +02:00
|
|
|
<p>Pas de compte ? <a class="auth" href="register">En créer un</a></p>
|
|
|
|
|
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>
|
2022-11-26 21:45:48 +01:00
|
|
|
<input required="" minlength="1" maxlength="1024" pattern="<?= USERNAME_REGEX ?>" id="username" name="username" type="text" placeholder="<?= PLACEHOLDER_USERNAME ?>">
|
2022-04-18 16:05:00 +02:00
|
|
|
<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>
|
2022-06-10 21:14:47 +02:00
|
|
|
<input required="" autocomplete="current-password" minlength="8" maxlength="1024" pattern="<?= PASSWORD_REGEX ?>" id="password" name="password" type="password" placeholder="<?= PLACEHOLDER_PASSWORD ?>">
|
2022-04-18 16:05:00 +02:00
|
|
|
<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>
|