Security: enforce per-user client restrictions on client, financial and bulk handlers and per-client reports

Agents restricted from a client could still edit, archive, restore or delete it, run bulk actions on it (edits, tags, archive, email, tickets) and add credits. Every selected client is now checked before anything is written.

Expense, trip and recurring expense edits now check the client the record already belongs to, not just the submitted one. Recurring expense delete, revenue edit/delete and task approval handlers gained the same check.

Per-client reports and the dashboard payment/ticket lists now hide clients the agent is denied. Company-wide totals are unchanged.
This commit is contained in:
johnnyq
2026-10-08 16:17:46 -04:00
parent 5acb1802bb
commit cd7ebc0a5f
15 changed files with 111 additions and 7 deletions

View File

@@ -364,6 +364,9 @@ if (isset($_GET['approve_ticket_task'])) {
exit;
}
$client_id = intval(getFieldById('tickets', $ticket_id, 'ticket_client_id'));
enforceClientAccess();
// Validate approver (deny)
if ($required_user > 0 && $required_user !== $session_user_id) {
flashAlert("You cannot approve that task", 'error');
@@ -399,6 +402,11 @@ if (isset($_GET['delete_ticket_task_approver'])) {
$approval_id = intval($_GET['delete_ticket_task_approver']);
$sql = mysqli_query($mysqli, "SELECT ticket_client_id FROM task_approvals LEFT JOIN tasks ON task_id = approval_task_id LEFT JOIN tickets ON ticket_id = task_ticket_id WHERE approval_id = $approval_id");
$row = mysqli_fetch_assoc($sql);
$client_id = intval($row['ticket_client_id'] ?? 0);
enforceClientAccess();
mysqli_query($mysqli, "DELETE FROM task_approvals WHERE approval_id = $approval_id");
logAudit("Task", "Delete", "$session_name deleted task approval request ($approval_id)", 0, 0);