fix no client showed up but says pending in purgatory

This commit is contained in:
KingKDot
2026-04-04 23:20:26 -05:00
parent 2070e640bb
commit 4966d6debd
+8 -1
View File
@@ -55,6 +55,9 @@ try {
try { try {
db.run(`ALTER TABLE clients ADD COLUMN enrollment_status TEXT NOT NULL DEFAULT 'pending'`); db.run(`ALTER TABLE clients ADD COLUMN enrollment_status TEXT NOT NULL DEFAULT 'pending'`);
} catch {} } catch {}
try {
db.run(`UPDATE clients SET enrollment_status='pending' WHERE enrollment_status IS NULL`);
} catch {}
try { try {
db.run(`ALTER TABLE clients ADD COLUMN public_key TEXT`); db.run(`ALTER TABLE clients ADD COLUMN public_key TEXT`);
} catch {} } catch {}
@@ -469,9 +472,13 @@ export function listClients(filters: ListFilters): ListResult {
} }
if (enrollmentFilter && enrollmentFilter !== "all") { if (enrollmentFilter && enrollmentFilter !== "all") {
if (enrollmentFilter === "pending") {
where.push("(enrollment_status='pending' OR enrollment_status IS NULL)");
} else {
where.push("enrollment_status=?"); where.push("enrollment_status=?");
params.push(enrollmentFilter); params.push(enrollmentFilter);
} }
}
if (osFilter && osFilter !== "all") { if (osFilter && osFilter !== "all") {
where.push("os=?"); where.push("os=?");
@@ -1089,7 +1096,7 @@ export function getPendingClients(): {
return db return db
.query<any>( .query<any>(
`SELECT id, host, os, user, ip, country, public_key as publicKey, key_fingerprint as keyFingerprint, last_seen as lastSeen `SELECT id, host, os, user, ip, country, public_key as publicKey, key_fingerprint as keyFingerprint, last_seen as lastSeen
FROM clients WHERE enrollment_status='pending' ORDER BY last_seen DESC`, FROM clients WHERE enrollment_status='pending' OR enrollment_status IS NULL ORDER BY last_seen DESC`,
) )
.all() .all()
.map((r: any) => ({ .map((r: any) => ({