integration de password.js à reinitialisation mdp

This commit is contained in:
2025-12-16 08:50:31 +01:00
parent 706d3ece23
commit 55a31a507c
3 changed files with 76 additions and 92 deletions

View File

@@ -1,100 +1,77 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Réinitialisation du mot de passe</title>
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css"
/>
<style> <head>
body { <meta charset="UTF-8" />
background: #f4f6f981; <meta name="viewport" content="width=device-width, initial-scale=1.0" />
height: 100vh; <title>Réinitialisation du mot de passe</title>
display: flex; <link href="/node_modules/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
justify-content: center; <link rel="shortcut icon" href="/favicon.png" type="image/png">
align-items: center;
} <style>
.reset-password-card { body {
width: 100%; height: 100vh;
max-width: 380px; display: flex;
} justify-content: center;
</style> align-items: center;
</head> }
<body>
<div class="card shadow reset-password-card"> .reset-password-card {
<div class="card-body p-4"> width: 100%;
<h1 class="text-center mb-4 fs-3">Nouveau mot de passe</h1> max-width: 380px;
<p class="text text-muted mb-4"> }
Pour réinitialiser votre mot de passe, veuillez saisir un nouveau mot </style>
de passe ainsi qu'une confirmation. </head>
<body>
<div class="card shadow reset-password-card">
<div class="card-body p-4">
<h1 class="text-center mb-4 fs-3">Nouveau mot de passe</h1>
<p class="text text-muted mb-4">
Pour réinitialiser votre mot de passe, veuillez saisir un nouveau mot
de passe ainsi qu'une confirmation.
</p>
<form id="password-form">
<main>
<div class="mb-4">
<label class="form-label">Nouveau mot de passe <br><span class="small"><span id="min8">8 caractères minimum</span>, incluant une <span id="uppercase">majuscule</span>, une <span id="lowercase">minuscule</span> et un <span id="digit">chiffre</span></span></label>
<input type="password" class="form-control" id="password" required />
</p> </div>
<div
id="errorMsg"
class="alert alert-danger text-center fs-1"
style="display: none"
>
Les mots de passe ne correspondent pas.
</div>
<form id="resetForm"> <div class="mb-2">
<div class="mb-4"> <label class="form-label">Confirmer le mot de passe</label>
<label class="form-label" <input type="password" class="form-control" id="passwordConfirm" required />
>Nouveau mot de passe (minimum 8 caractères)</label </div>
> <div class="mb-3">
<input <label for="showPassword" class="mt-3">
type="password"
class="form-control"
id="password"
required
/>
<small id="passwordIndicator" class="fw-bold"></small>
</div>
<div class="mb-3">
<label class="form-label"
>Confirmer le mot de passe</label
>
<input
type="password"
class="form-control"
id="confirmPassword"
required
/>
<label for="showPassword" class="mt-3">
<input type="checkbox" id="showPassword" /> <input type="checkbox" id="showPassword" />
Voir le mot de passe Voir le mot de passe
</label> </label>
</div> </div>
<div
id="successMsg"
class="alert alert-success text-center"
style="display: none"
>
Votre mot de passe a été modifié avec succès !
</div>
<button class="btn btn-primary w-100" type="submit">
Changer le mot de passe
</button>
<div class="text-center mt-3"> <button class="btn btn-primary w-100" type="submit">
<a Changer le mot de passe
href="../html/page_de_connexion.html" </button>
class="text-decoration-none" <div class="text-center mt-3">
>Retour à la connexion</a <a href="../html/page_de_connexion.html" class="text-decoration-none">Retour à la connexion</a>
</form> </form>
</div> </main>
</div>
</div> </div>
<script src="../js/reinitialisation_du_mot_de_passe.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script> <script src="/js/password.js"></script>
</body> </body>
</html>
</html>

View File

@@ -40,7 +40,7 @@ form.addEventListener('submit', function(e) {
if (pass.length < minLength) { if (pass.length < minLength) {
errorMsg.style.display = 'block'; errorMsg.style.display = 'block';
errorMsg.textContent = `Le mot de passe doit contenir au moins ${minLength} caractères.`; errorMsg.textContent = `Le mot de passe doit contenir au moins ${minLength} caractères.`;
return; return;8 caractères minimum
} }
//Correspondance //Correspondance
@@ -61,7 +61,7 @@ form.addEventListener('submit', function(e) {
showPasswordCheckbox.addEventListener('change', function() { showPasswordCheckbox.addEventListener('change', function() {
if (this.checked) { if (this.checked) {8 caractères minimum
password.type = 'text'; password.type = 'text';
confirmPassword.type = 'text'; confirmPassword.type = 'text';

View File

@@ -81,10 +81,17 @@ passwordForm.addEventListener('submit', function(event) {
password !== confirmPassword) { password !== confirmPassword) {
event.preventDefault(); event.preventDefault();
const main = document.querySelector('main');
const existingAlert = main.querySelector('#password-alert');
if (existingAlert) {
existingAlert.remove();
}
const alertElt = document.createElement('div'); const alertElt = document.createElement('div');
alertElt.id = 'password-alert';
alertElt.className = 'alert alert-danger text-center'; alertElt.className = 'alert alert-danger text-center';
alertElt.textContent = "Le mot de passe ne respecte pas les critères requis ou la confirmation ne correspond pas."; alertElt.textContent = "Le mot de passe ne respecte pas les critères requis ou la confirmation ne correspond pas.";
document.querySelector('main').prepend(alertElt); main.prepend(alertElt);
window.scrollTo(0, 0); window.scrollTo(0, 0);