2022-04-23 01:57:43 +02:00
|
|
|
<?php require "../../common/top.php"; ?>
|
2021-02-12 15:32:48 +01:00
|
|
|
|
2021-02-17 22:48:49 +01:00
|
|
|
<p>
|
2022-04-18 16:05:00 +02:00
|
|
|
Vous pouvez ici changer le mot de passe permettant d'accéder à votre compte Niver.
|
2021-02-17 22:48:49 +01:00
|
|
|
</p>
|
2021-02-12 15:32:48 +01:00
|
|
|
|
2021-02-17 22:48:49 +01:00
|
|
|
<form method="post">
|
2022-04-18 16:05:00 +02:00
|
|
|
<label for="currentPassword">Mot de passe actuel</label><br>
|
|
|
|
<input required="" autocomplete="current-password" minlength="8" maxlength="1024" pattern="<?= PASSWORD_REGEX ?>" id="currentPassword" name="currentPassword" type="password" placeholder="************"><br>
|
2021-02-12 15:32:48 +01:00
|
|
|
|
2022-04-18 16:05:00 +02:00
|
|
|
<label for="newPassword">Nouveau mot de passe</label><br>
|
|
|
|
<input required="" autocomplete="new-password" minlength="8" maxlength="1024" pattern="<?= PASSWORD_REGEX ?>" id="newPassword" name="newPassword" type="password" placeholder="************"><br>
|
2021-02-12 15:32:48 +01:00
|
|
|
|
2022-04-18 16:05:00 +02:00
|
|
|
<input type="submit">
|
2021-02-17 22:48:49 +01:00
|
|
|
</form>
|
2021-02-12 15:32:48 +01:00
|
|
|
|
2021-02-17 22:48:49 +01:00
|
|
|
<?php
|
2021-02-12 15:32:48 +01:00
|
|
|
|
2021-02-17 22:48:49 +01:00
|
|
|
if (isset($_SESSION['username']) AND isset($_POST['newPassword']) AND isset($_POST['currentPassword'])) {
|
2021-02-12 15:32:48 +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['newPassword']);
|
2021-02-12 15:32:48 +01:00
|
|
|
|
2022-05-20 02:19:45 +02:00
|
|
|
if (checkPassword($_SESSION['username'], $_POST['currentPassword'])) {
|
2021-02-12 15:32:48 +01:00
|
|
|
|
2022-04-18 16:05:00 +02:00
|
|
|
$username = $_SESSION['username'];
|
|
|
|
$newPassword = password_hash($_POST['newPassword'], PASSWORD_DEFAULT);
|
2021-02-12 15:32:48 +01:00
|
|
|
|
2022-04-18 16:05:00 +02:00
|
|
|
$db = new PDO('sqlite:' . DB_PATH);
|
2021-02-12 15:32:48 +01:00
|
|
|
|
2022-04-18 16:05:00 +02:00
|
|
|
$stmt = $db->prepare("UPDATE users SET password = :password WHERE username = :username");
|
2021-02-12 15:32:48 +01:00
|
|
|
|
2022-04-18 16:05:00 +02:00
|
|
|
$stmt->bindParam(':username', $username);
|
|
|
|
$stmt->bindParam(':password', $newPassword);
|
2021-02-12 15:32:48 +01:00
|
|
|
|
2022-04-18 16:05:00 +02:00
|
|
|
$stmt->execute();
|
2021-02-12 15:32:48 +01:00
|
|
|
|
2022-04-18 16:05:00 +02:00
|
|
|
} else {
|
|
|
|
echo "<br>Le mot de passe actuel n'est pas bon !";
|
|
|
|
}
|
2021-02-12 15:32:48 +01:00
|
|
|
|
2021-02-17 22:48:49 +01:00
|
|
|
}
|
2021-02-12 15:32:48 +01:00
|
|
|
|
2021-02-17 22:48:49 +01:00
|
|
|
?>
|
2021-02-12 15:32:48 +01:00
|
|
|
|
2022-04-23 01:57:43 +02:00
|
|
|
<?php require "../../common/bottom.php"; ?>
|