Added authentication functionality and simple role based model

This commit is contained in:
2026-02-11 15:02:37 -08:00
parent c247631de6
commit 11889e3f93
17 changed files with 341 additions and 57 deletions

View File

@@ -1,25 +1,27 @@
<?php
require 'db.php';
require 'auth.php';
header('Content-Type: application/json');
$data = json_decode(file_get_contents('php://input'), true);
require_login();
$user_id = current_user_id();
$data = json_decode(file_get_contents('php://input'), true);
if (!$data || !is_array($data)) {
echo json_encode(['success' => false, 'message' => 'Invalid input']);
exit;
}
$stmt = $pdo->prepare("UPDATE projects SET sort_order = ? WHERE id = ?");
$stmt = $pdo->prepare("UPDATE projects SET sort_order = ? WHERE id = ? AND user_id = ?");
foreach ($data as $item) {
$id = $item['id'];
$order = $item['order'];
$id = $item['id'] ?? null;
$order = $item['order'] ?? null;
if (!is_numeric($id) || !is_numeric($order)) continue;
$stmt->execute([$order, $id]);
$stmt->execute([(int)$order, (int)$id, $user_id]);
}
echo json_encode(['success' => true]);
exit;