honeypotField(); if ($csrfToken === '') { $csrfToken = bin2hex(random_bytes(16)); $_SESSION['forgot_password_form_token'] = $csrfToken; } if ($_SERVER['REQUEST_METHOD'] === 'POST') { $username = trim((string) ($_POST['username'] ?? '')); $postedToken = (string) ($_POST['csrf_token'] ?? ''); if ($postedToken === '' || !hash_equals($csrfToken, $postedToken)) { $error = 'Die Formularprüfung ist fehlgeschlagen. Bitte versuche es erneut.'; } else { $protection = $formProtection->guard('password_reset', $_POST); if (!($protection['success'] ?? false)) { $error = implode(' ', array_map('strval', (array) ($protection['errors'] ?? []))); } else { $origin = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http') . '://' . ($_SERVER['HTTP_HOST'] ?? 'localhost'); $result = $registration->sendPasswordReset($username, $origin); if ($result['success'] ?? false) { $message = (string) ($result['message'] ?? ''); $csrfToken = bin2hex(random_bytes(16)); $_SESSION['forgot_password_form_token'] = $csrfToken; } else { $error = (string) ($result['message'] ?? ''); } } } } ?> Passwort vergessen