- Remove redundant requireAuth call since apiOrAuth middleware handles authentication - This was causing 'Authentication required' error even with valid API key
23 lines
711 B
PHP
23 lines
711 B
PHP
<?php
|
|
// Teste do AuthMiddleware
|
|
require_once __DIR__ . '/vendor/autoload.php';
|
|
|
|
// Load environment
|
|
\App\Core\EnvironmentLoader::load();
|
|
|
|
// Simular Authorization header
|
|
$_SERVER['HTTP_AUTHORIZATION'] = 'Bearer mf_redirect_2025';
|
|
|
|
echo "Testing AuthMiddleware::apiOrAuth()\n";
|
|
echo "REDIRECTS_API_KEY: " . ($_ENV['REDIRECTS_API_KEY'] ?? 'NOT_FOUND') . "\n";
|
|
echo "Auth::check(): " . (\App\Core\Auth::check() ? 'true' : 'false') . "\n";
|
|
echo "Authorization header: " . ($_SERVER['HTTP_AUTHORIZATION'] ?? 'NOT_FOUND') . "\n";
|
|
|
|
// Test apiOrAuth
|
|
try {
|
|
\App\Core\AuthMiddleware::apiOrAuth();
|
|
echo "apiOrAuth: PASSED\n";
|
|
} catch (Exception $e) {
|
|
echo "apiOrAuth: FAILED - " . $e->getMessage() . "\n";
|
|
}
|