pdo(); $flash = $app->flash()->get(); $error = ''; $info = ''; $email = $_SESSION['verify_email'] ?? ''; if ($_SERVER['REQUEST_METHOD'] === 'POST') { $action = $_POST['action'] ?? 'verify'; $email = trim((string)($_POST['email'] ?? '')); $code = strtoupper(trim((string)($_POST['code'] ?? ''))); $auth = new \App\Auth($app); $mailer = new \App\Mailer($app); if ($action === 'resend') { try { $stmt = $app->pdo()->prepare('SELECT id, display_name, status FROM users u JOIN user_profiles p ON p.user_id = u.id WHERE u.email = :email LIMIT 1'); $stmt->execute(['email' => $email]); $row = $stmt->fetch(PDO::FETCH_ASSOC); if (!$row) { throw new RuntimeException('E-Mail nicht gefunden.'); } $userId = (int)$row['id']; $codeNew = $auth->createVerifyCode($userId, $email); $mailer->sendTemplate('registration_resend_code', $email, [ 'code' => $codeNew, 'display_name' => $row['display_name'] ?? '', ]); $info = 'Neuer Code wurde versendet.'; $_SESSION['verify_email'] = $email; } catch (Throwable $e) { $error = $e->getMessage(); } } else { try { $userId = $auth->verifyCode($email, $code); $_SESSION['user_id'] = $userId; unset($_SESSION['verify_email']); $mailer->sendTemplate('registration_welcome', $email, ['display_name' => $email]); $app->flash()->set('success', 'Registrierung bestätigt. Willkommen!'); redirect('/dashboard'); } catch (Throwable $e) { $error = $e->getMessage(); } } } ?>
Bestätigung

Registrierung bestätigen

Wir haben dir einen 6-stelligen Code gesendet. Bitte gib ihn hier ein.

Fehler: