Version stable, aprelic, connexion CFRS et autres corrections

This commit is contained in:
Oleg Barykin committed 2026-04-17 20:18:11 +02:00
1 parent 865de8a976
commit e9d0010451
62 files changed
+17483 -7256

No files matched your search

+55 -40
View File
@@ -1,37 +1,41 @@
<?php
require_once __DIR__ . '/../includes/init_praticien.php';
require_once __DIR__ . '/../includes/init_praticien.php';
$success = $erreur = '';
$id = $_SESSION['compte_id'];
$success = $erreur = '';
$id = $_SESSION['compte_id'];
// Récupérer e-mail actuel
$stmt = $pdo->prepare("SELECT email FROM compte WHERE id = ?");
$stmt->execute([$id]);
$compte = $stmt->fetch();
// Récupérer e-mail actuel
$stmt = $pdo->prepare("SELECT email, mot_de_passe FROM compte WHERE id = ?");
$stmt->execute([$id]);
$compte = $stmt->fetch();
if (!$compte) {
if (! $compte) {
die($translations['compte_introuvable']);
}
}
$email_actuel = $compte['email'];
$email_actuel = $compte['email'];
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
require_post_csrf();
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$nouvel_email = trim($_POST['email'] ?? '');
$mdp1 = $_POST['mot_de_passe'] ?? '';
$mdp2 = $_POST['confirm_mot_de_passe'] ?? '';
$mdpActuel = $_POST['mot_de_passe_actuel'] ?? '';
$mdp1 = $_POST['mot_de_passe'] ?? '';
$mdp2 = $_POST['confirm_mot_de_passe'] ?? '';
if (!filter_var($nouvel_email, FILTER_VALIDATE_EMAIL)) {
if (! password_verify($mdpActuel, (string) ($compte['mot_de_passe'] ?? ''))) {
$erreur = $translations['erreur_mdp_actuel_incorrect'] ?? 'Mot de passe actuel incorrect.';
} elseif (! filter_var($nouvel_email, FILTER_VALIDATE_EMAIL)) {
$erreur = $translations['erreur_email_non_valide'];
} elseif ($mdp1 && ($mdp1 !== $mdp2 || strlen($mdp1) < 8)) {
$erreur = $translations['erreur_mdp_invalides'];
} else {
// Vérifier si l'email est déjà pris (sauf si c’est le sien)
$stmt = $pdo->prepare("SELECT id FROM compte WHERE email = ? AND id != ?");
$stmt->execute([$nouvel_email, $id]);
if ($stmt->fetch()) {
$erreur = $translations['err_email_deja_utilise'];
} else {
// Mise à jour
if ($mdp1) {
$hash = password_hash($mdp1, PASSWORD_DEFAULT);
$stmt = $pdo->prepare("UPDATE compte SET email = ?, mot_de_passe = ? WHERE id = ?");
@@ -40,37 +44,48 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$stmt = $pdo->prepare("UPDATE compte SET email = ? WHERE id = ?");
$stmt->execute([$nouvel_email, $id]);
}
$success = $translations['success_compte_mis_a_jour'];
// Optionnel : mettre à jour $email_actuel pour refléter l'écran
$success = $translations['success_compte_mis_a_jour'];
$email_actuel = $nouvel_email;
// garder la valeur en mémoire pour la suite de la page
$compte['mot_de_passe'] = $mdp1 ? $hash : $compte['mot_de_passe'];
}
}
}
require_once '../includes/header.php';
}
require_once '../includes/header.php';
?>
<div class="main1">
<div class="container py-5">
<form method="POST" class="shadow p-4 rounded bg-light">
<h2 class="text-center mb-4"><?= htmlspecialchars($translations['h2_infos_connexion']) ?></h2>
<input type="hidden" name="csrf_token" value="<?php echo htmlspecialchars(ensure_csrf_token(), ENT_QUOTES, 'UTF-8') ?>">
<h2 class="text-center mb-4"><?php echo htmlspecialchars($translations['h2_infos_connexion']) ?></h2>
<?php if (!empty($erreur)): ?>
<div class="alert alert-danger"><?= htmlspecialchars($erreur) ?></div>
<?php if (! empty($erreur)): ?>
<div class="alert alert-danger"><?php echo htmlspecialchars($erreur) ?></div>
<?php endif; ?>
<?php if (!empty($success)): ?>
<div class="alert alert-success"><?= htmlspecialchars($success) ?></div>
<?php if (! empty($success)): ?>
<div class="alert alert-success"><?php echo htmlspecialchars($success) ?></div>
<?php endif; ?>
<div class="mb-3">
<label class="form-label"><?= htmlspecialchars($translations['label_email']) ?></label>
<input type="email" name="email" class="form-control" value="<?= htmlspecialchars($email_actuel ?? '') ?>" required>
<label class="form-label"><?php echo htmlspecialchars($translations['label_email']) ?></label>
<input type="email" name="email" class="form-control" value="<?php echo htmlspecialchars($email_actuel ?? '') ?>" required>
</div>
<div class="mb-3">
<label class="form-label"><?php echo htmlspecialchars($translations['label_mdp_actuel'] ?? 'Mot de passe actuel') ?></label>
<div class="field-wrapper">
<input type="password" name="mot_de_passe_actuel" id="mot_de_passe_actuel" class="form-control"
placeholder="<?php echo htmlspecialchars($translations['placeholder_mdp_actuel'] ?? 'Entrez votre mot de passe actuel') ?>" required>
<span class="toggle-password" onclick="toggle('mot_de_passe_actuel')">👁️</span>
</div>
</div>
<div class="mb-3">
<label class="form-label"><?= htmlspecialchars($translations['label_nouveau_mdp_opt']) ?></label>
<label class="form-label"><?php echo htmlspecialchars($translations['label_nouveau_mdp_opt']) ?></label>
<div class="field-wrapper">
<input type="password" name="mot_de_passe" id="mot_de_passe" class="form-control"
placeholder="<?= htmlspecialchars($translations['placeholder_nouveau_mdp']) ?>">
placeholder="<?php echo htmlspecialchars($translations['placeholder_nouveau_mdp']) ?>">
<span class="toggle-password" onclick="toggle('mot_de_passe')">👁️</span>
</div>
<div class="strength-bar mt-2">
@@ -79,21 +94,21 @@ require_once '../includes/header.php';
<div class="strength-fill"></div>
</div>
<div id="niveau-securite" class="mb-2 text-muted">
<?= htmlspecialchars($translations['securite_label']) ?> : <?= htmlspecialchars($translations['securite_vide']) ?>
<?php echo htmlspecialchars($translations['securite_label']) ?> : <?php echo htmlspecialchars($translations['securite_vide']) ?>
</div>
</div>
<div class="mb-3">
<label class="form-label"><?= htmlspecialchars($translations['label_confirmer_mdp']) ?></label>
<label class="form-label"><?php echo htmlspecialchars($translations['label_confirmer_mdp']) ?></label>
<div class="field-wrapper">
<input type="password" name="confirm_mot_de_passe" id="confirm_mot_de_passe" class="form-control"
placeholder="<?= htmlspecialchars($translations['placeholder_confirmer_mdp']) ?>">
placeholder="<?php echo htmlspecialchars($translations['placeholder_confirmer_mdp']) ?>">
<span class="toggle-password" onclick="toggle('confirm_mot_de_passe')">👁️</span>
</div>
</div>
<div class="mt-4 text-center">
<button type="submit" class="btn btn-primary">
<?= htmlspecialchars($translations['btn_mettre_a_jour']) ?>
<?php echo htmlspecialchars($translations['btn_mettre_a_jour']) ?>
</button>
</div>
</div>
@@ -112,11 +127,11 @@ document.getElementById('mot_de_passe').addEventListener('input', function () {
segments.forEach(s => s.style.backgroundColor = '#ccc');
// base label
const label = <?= json_encode($translations['securite_label'], JSON_UNESCAPED_UNICODE) ?>;
const faible = <?= json_encode($translations['securite_faible'], JSON_UNESCAPED_UNICODE) ?>;
const moyen = <?= json_encode($translations['securite_moyen'], JSON_UNESCAPED_UNICODE) ?>;
const fort = <?= json_encode($translations['securite_fort'], JSON_UNESCAPED_UNICODE) ?>;
const vide = <?= json_encode($translations['securite_vide'], JSON_UNESCAPED_UNICODE) ?>;
const label = <?php echo json_encode($translations['securite_label'], JSON_UNESCAPED_UNICODE) ?>;
const faible = <?php echo json_encode($translations['securite_faible'], JSON_UNESCAPED_UNICODE) ?>;
const moyen = <?php echo json_encode($translations['securite_moyen'], JSON_UNESCAPED_UNICODE) ?>;
const fort = <?php echo json_encode($translations['securite_fort'], JSON_UNESCAPED_UNICODE) ?>;
const vide = <?php echo json_encode($translations['securite_vide'], JSON_UNESCAPED_UNICODE) ?>;
niveauText.textContent = `${label} : ${vide}`;
niveauText.classList.remove("text-danger", "text-warning", "text-success");
@@ -152,7 +167,7 @@ document.getElementById('mot_de_passe').addEventListener('input', function () {
</div>
<footer class="site-footer">
<div class="container">
<p><?= $translations['copyr'] ?></p>
<p><?php echo $translations['copyr'] ?></p>
</div>
</footer>
</body>