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
This commit is contained in:
1 parent
c8e92ead2e
commit
f88fc2412b
2 files changed
+22
-2
No files matched your search
@@ -373,8 +373,6 @@ class UserController extends BaseController
|
||||
public function apiGetUsers(): void
|
||||
{
|
||||
try {
|
||||
$this->requireAuth();
|
||||
|
||||
if (!Auth::isAdmin()) {
|
||||
http_response_code(403);
|
||||
header('Content-Type: application/json');
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
<?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";
|
||||
}
|
||||
Reference in new issue
Block a user