From ffc824f27cafcd5c33ec97e529610a53b6ce5753 Mon Sep 17 00:00:00 2001 From: Niek Rabelink Date: Thu, 10 Sep 2026 12:49:37 +0200 Subject: [PATCH] Improve error handling and feedback for password reset functionality --- auth/forgot-password.php | 17 +++++++++++++---- config/config.php | 2 +- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/auth/forgot-password.php b/auth/forgot-password.php index 23de8b3..8e36f08 100644 --- a/auth/forgot-password.php +++ b/auth/forgot-password.php @@ -53,13 +53,22 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { // Verstuur herstelmail via de nieuwe FocizMailer $mailResult = FocizMailer::sendPasswordResetEmail($user['email'], $user['name'], $resetUrl); if (!$mailResult['success']) { - error_log("Fout bij verzenden wachtwoordherstel mail naar {$email}: " . ($mailResult['error'] ?? 'Onbekend')); + $errMsg = $mailResult['error'] ?? 'Mailserver fout'; + error_log("Fout bij verzenden wachtwoordherstel mail naar {$email}: {$errMsg}"); + $error = "De herstelmail kon niet worden verzonden via de mailserver: " . htmlspecialchars($errMsg); + } else { + $submitted = true; + } + } else { + // In development omgeving geven we directe diagnostische feedback + if (defined('APP_ENV') && APP_ENV === 'development') { + $error = "Er is geen Fociz account gevonden met het e-mailadres '{$email}'. Controleer of dit e-mailadres correct is ingevoerd."; + } else { + // Anti-enumeratie op productie: toon altijd succes + $submitted = true; } } - // Anti-enumeratie: Toon altijd succes ongeacht of het e-mailadres bestaat - $submitted = true; - } catch (Throwable $e) { error_log("Wachtwoord vergeten fout: " . $e->getMessage()); $error = "Er is een technische fout opgetreden. Probeer het over enkele ogenblikken opnieuw."; diff --git a/config/config.php b/config/config.php index 127691e..fd30565 100644 --- a/config/config.php +++ b/config/config.php @@ -136,7 +136,7 @@ define('SMTP_PORT', (int)fociz_env('SMTP_PORT', 587)); define('SMTP_USER', fociz_env('SMTP_USER', 'info@fociz.nl')); define('SMTP_PASS', fociz_env('SMTP_PASS', '6swpQSBg5uWFmjar7F6a')); define('SMTP_SECURE', fociz_env('SMTP_SECURE', 'tls')); // 'tls' (STARTTLS port 587) of 'ssl' (port 465) -define('SMTP_FROM_EMAIL', fociz_env('SMTP_FROM_EMAIL', 'no-reply@fociz.nl')); +define('SMTP_FROM_EMAIL', fociz_env('SMTP_FROM_EMAIL', 'info@fociz.nl')); define('SMTP_FROM_NAME', fociz_env('SMTP_FROM_NAME', 'Fociz')); define('SMTP_REPLY_TO', fociz_env('SMTP_REPLY_TO', 'info@fociz.nl'));