prepare('SELECT * FROM users WHERE email = :email LIMIT 1'); $stmt->execute(['email' => $email]); $user = $stmt->fetch(); if (!$user) { $error = 'Identifiants invalides.'; } else { $lockedUntil = $user['locked_until'] ?? null; if ($lockedUntil && strtotime((string) $lockedUntil) > time()) { $seconds = max(1, strtotime((string) $lockedUntil) - time()); $error = 'Compte temporairement bloqué. Réessayez dans ' . $seconds . ' secondes.'; } elseif (password_verify($password, (string) $user['password_hash'])) { $reset = db()->prepare('UPDATE users SET failed_attempts = 0, locked_until = NULL WHERE id = :id'); $reset->execute(['id' => (int) $user['id']]); login_user($user); set_flash('success', 'Connexion réussie.'); redirect('index.php'); } else { $attempts = (int) $user['failed_attempts'] + 1; $locked = $attempts >= 5 ? date('Y-m-d H:i:s', time() + 30) : null; $update = db()->prepare('UPDATE users SET failed_attempts = :failed_attempts, locked_until = :locked_until WHERE id = :id'); $update->bindValue(':failed_attempts', $attempts, PDO::PARAM_INT); $update->bindValue(':locked_until', $locked); $update->bindValue(':id', (int) $user['id'], PDO::PARAM_INT); $update->execute(); $error = $attempts >= 5 ? '5 tentatives atteintes. Compte bloqué pendant 30 secondes.' : 'Identifiants invalides. Tentative ' . $attempts . '/5.'; } } } render_header('Connexion', ['description' => 'Se connecter à RJLRESAKA pour accéder au registre des sportifs.']); ?>

Authentification

Connexion sécurisée

5 tentatives maximum, puis pause automatique de 30 secondes.