<?php
// debug.php - run via CLI on server
$_SERVER['REQUEST_METHOD'] = 'POST';
$_SERVER['REQUEST_URI'] = '/api/v1/auth/login';
$_SERVER['HTTP_HOST'] = 'api.fahrschultermin.de';
$_SERVER['HTTPS'] = 'on';

$config = require __DIR__ . '/config/app.php';

try {
    \App\Support\Database::configure($config);

    $userRepo = new \App\Repositories\UserRepository();
    $user = $userRepo->findByEmail('admin@nordring.test');

    echo "User found: " . ($user ? 'YES' : 'NO') . "\n";
    if ($user) {
        echo "Hash: " . substr($user['password_hash'], 0, 20) . "...\n";
        echo "Verify: " . (password_verify('secret123', $user['password_hash']) ? 'YES' : 'NO') . "\n";
    }
} catch (Throwable $e) {
    echo "ERROR: " . $e->getMessage() . "\n";
    echo "File: " . $e->getFile() . ":" . $e->getLine() . "\n";
    echo "Trace: " . $e->getTraceAsString() . "\n";
}