enforce purgatory

This commit is contained in:
KingKDot
2026-03-26 15:28:49 -05:00
parent 0ac793152a
commit 9751807401
4 changed files with 2 additions and 81 deletions
@@ -1,5 +1,5 @@
import { authenticateRequest } from "../../auth";
import { getConfig, updateEnrollmentConfig } from "../../config";
import { getConfig } from "../../config";
import {
getPendingClients,
getEnrollmentStats,
@@ -49,37 +49,6 @@ export async function handleEnrollmentRoutes(
});
}
// PUT /api/enrollment/settings
if (req.method === "PUT" && url.pathname === "/api/enrollment/settings") {
const user = await authenticateRequest(req);
if (!user) return new Response("Unauthorized", { status: 401 });
if (user.role !== "admin") return new Response("Forbidden", { status: 403 });
let body: any;
try {
body = await req.json();
} catch {
return Response.json({ error: "Invalid JSON" }, { status: 400 });
}
if (typeof body?.requireApproval !== "boolean") {
return Response.json({ error: "requireApproval must be a boolean" }, { status: 400 });
}
await updateEnrollmentConfig({ requireApproval: body.requireApproval });
logAudit({
timestamp: Date.now(),
username: user.username,
ip: "server",
action: AuditAction.ENROLLMENT_SETTINGS,
success: true,
details: JSON.stringify({ enrollment: { requireApproval: body.requireApproval } }),
});
return Response.json({ ok: true, requireApproval: body.requireApproval });
}
// POST /api/enrollment/:id/approve
const approveMatch = url.pathname.match(/^\/api\/enrollment\/([^/]+)\/approve$/);
if (req.method === "POST" && approveMatch) {