fix: Add missing API routes and methods
- Add recent-activity route to Users module - Add apiGetRecentActivity method to UserController - Fix composer autoloader path in index.php - Install composer dependencies on server
This commit is contained in:
1 parent
362d2f9488
commit
f670e9301a
4 files changed
+84
-4
No files matched your search
@@ -916,4 +916,51 @@ class UserController extends BaseController
|
||||
echo 'Erro interno';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* API: Get recent activity
|
||||
*/
|
||||
public function apiGetRecentActivity(): void
|
||||
{
|
||||
try {
|
||||
$this->requireAuth();
|
||||
|
||||
if (!Auth::isAdmin()) {
|
||||
http_response_code(403);
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode(['error' => 'Acesso negado']);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Mock data for now - implement real activity tracking later
|
||||
$activities = [
|
||||
[
|
||||
'id' => 1,
|
||||
'user_id' => 1,
|
||||
'action' => 'login',
|
||||
'description' => 'Utilizador fez login',
|
||||
'created_at' => date('Y-m-d H:i:s')
|
||||
],
|
||||
[
|
||||
'id' => 2,
|
||||
'user_id' => 1,
|
||||
'action' => 'redirect_created',
|
||||
'description' => 'Criou novo redirect',
|
||||
'created_at' => date('Y-m-d H:i:s', strtotime('-1 hour'))
|
||||
]
|
||||
];
|
||||
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode([
|
||||
'success' => true,
|
||||
'data' => $activities
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
ErrorReporter::report($e, ['context' => 'api_get_recent_activity']);
|
||||
http_response_code(500);
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode(['error' => 'Erro interno do servidor']);
|
||||
}
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@@ -31,4 +31,10 @@ $router->delete(
|
||||
'/api/admin/users/{int:id}',
|
||||
[UserController::class, 'apiDeleteUser'],
|
||||
[AuthMiddleware::class, 'requireAuth']
|
||||
);
|
||||
|
||||
$router->get(
|
||||
'/api/admin/users/recent-activity',
|
||||
[UserController::class, 'apiGetRecentActivity'],
|
||||
[AuthMiddleware::class, 'requireAuth']
|
||||
);
|
||||
+4
-4
@@ -8,13 +8,13 @@
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"App\\": "app/",
|
||||
"App\\": "./",
|
||||
"Database\\": "database/"
|
||||
},
|
||||
"classmap": [
|
||||
"app/Modules/*/Models/",
|
||||
"app/Modules/*/Services/",
|
||||
"app/Modules/*/Controllers/"
|
||||
"Modules/*/Models/",
|
||||
"Modules/*/Services/",
|
||||
"Modules/*/Controllers/"
|
||||
]
|
||||
},
|
||||
"autoload-dev": {
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
// Teste simples do autoloader
|
||||
require_once __DIR__ . '/vendor/autoload.php';
|
||||
|
||||
echo "Testing autoloader...\n";
|
||||
|
||||
// Test if classes can be loaded
|
||||
try {
|
||||
$class = new \App\Modules\Advertising\Controllers\BrandApiController();
|
||||
echo "✓ BrandApiController loaded successfully\n";
|
||||
} catch (Exception $e) {
|
||||
echo "✗ Error loading BrandApiController: " . $e->getMessage() . "\n";
|
||||
}
|
||||
|
||||
try {
|
||||
$class = new \App\Modules\Users\Controllers\UserController();
|
||||
echo "✓ UserController loaded successfully\n";
|
||||
} catch (Exception $e) {
|
||||
echo "✗ Error loading UserController: " . $e->getMessage() . "\n";
|
||||
}
|
||||
|
||||
try {
|
||||
$class = new \App\Core\Router();
|
||||
echo "✓ Router loaded successfully\n";
|
||||
} catch (Exception $e) {
|
||||
echo "✗ Error loading Router: " . $e->getMessage() . "\n";
|
||||
}
|
||||
Reference in new issue
Block a user