fix user permissions + improve notification system

This commit is contained in:
KingKDot
2026-04-13 14:11:49 -05:00
parent c56a9f16f4
commit f28c0d33a9
12 changed files with 257 additions and 24 deletions
+15
View File
@@ -102,6 +102,8 @@ export interface AuditLogFilters {
startDate?: number;
endDate?: number;
successOnly?: boolean;
allowedClientIds?: string[];
deniedClientIds?: string[];
}
export function logAudit(entry: AuditLogEntry): void {
@@ -216,6 +218,19 @@ export function getAuditLogs(filters: AuditLogFilters = {}): {
where.push("success = 1");
}
if (filters.allowedClientIds) {
if (filters.allowedClientIds.length === 0) {
return { logs: [], total: 0, page, pageSize };
}
const placeholders = filters.allowedClientIds.map(() => "?").join(",");
where.push(`(target_client_id IN (${placeholders}) OR target_client_id IS NULL)`);
params.push(...filters.allowedClientIds);
} else if (filters.deniedClientIds && filters.deniedClientIds.length > 0) {
const placeholders = filters.deniedClientIds.map(() => "?").join(",");
where.push(`(target_client_id NOT IN (${placeholders}) OR target_client_id IS NULL)`);
params.push(...filters.deniedClientIds);
}
const whereSql = where.length ? `WHERE ${where.join(" AND ")}` : "";
const countQuery = `SELECT COUNT(*) as total FROM audit_logs ${whereSql}`;