diff --git a/crm/Modules/Users/Controllers/UserController.php b/crm/Modules/Users/Controllers/UserController.php index 6238f6b..77596e4 100644 --- a/crm/Modules/Users/Controllers/UserController.php +++ b/crm/Modules/Users/Controllers/UserController.php @@ -927,9 +927,13 @@ class UserController extends BaseController public function apiGetRecentActivity(): void { try { - $this->requireAuth(); + // 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 (!Auth::isAdmin()) { + if (!$isAdmin && !$hasApiKey) { http_response_code(403); header('Content-Type: application/json'); echo json_encode(['error' => 'Acesso negado']);