Fifth Commit
This commit is contained in:
@@ -7,9 +7,20 @@
|
||||
require_once __DIR__ . '/../config/db.php';
|
||||
require_once __DIR__ . '/../config/helpers.php';
|
||||
|
||||
session_start();
|
||||
if (!isset($_SESSION['user_id'])) {
|
||||
jsonResponse(['error' => 'Unauthorized'], 401);
|
||||
}
|
||||
|
||||
handlePreflight();
|
||||
|
||||
$method = getMethod();
|
||||
if ($method !== 'GET') {
|
||||
if (!isset($_SESSION['role']) || $_SESSION['role'] !== 'admin') {
|
||||
jsonResponse(['error' => 'Forbidden: Admin access required'], 403);
|
||||
}
|
||||
}
|
||||
|
||||
$db = getDB();
|
||||
|
||||
switch ($method) {
|
||||
|
||||
Reference in New Issue
Block a user