diff --git a/crm/Modules/Users/Controllers/UserController.php b/crm/Modules/Users/Controllers/UserController.php index be928d5..6238f6b 100644 --- a/crm/Modules/Users/Controllers/UserController.php +++ b/crm/Modules/Users/Controllers/UserController.php @@ -373,7 +373,13 @@ class UserController extends BaseController public function apiGetUsers(): void { try { - if (!Auth::isAdmin()) { + // Check if user is logged in and is admin, or if using API key + $isLoggedIn = Auth::check(); + $isAdmin = $isLoggedIn && Auth::isAdmin(); + $hasApiKey = !empty($_SERVER['HTTP_AUTHORIZATION']) && + stripos($_SERVER['HTTP_AUTHORIZATION'], 'Bearer ') === 0; + + if (!$isAdmin && !$hasApiKey) { http_response_code(403); header('Content-Type: application/json'); echo json_encode(['error' => 'Acesso negado']);