Files
MoneyFlix/crm/test_auth_middleware.php
T
1sonhador f88fc2412b fix: Remove requireAuth call from UserController::apiGetUsers
- Remove redundant requireAuth call since apiOrAuth middleware handles authentication
- This was causing 'Authentication required' error even with valid API key
2025-10-15 14:32:28 +01:00

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";
}