Add confirmed admin override for provisioning player checks

This commit is contained in:
2026-10-05 18:16:02 -04:00
parent 4b0f341d64
commit 8abe71b915
20 changed files with 362 additions and 26 deletions
@@ -0,0 +1,16 @@
import { json } from '@sveltejs/kit';
import { authBody, authError } from '$lib/server/auth/http.js';
import { enableSafetyOverride } from '$lib/server/provisioning/safety-override.js';
import { kickProvisioning } from '$lib/server/pipeline/worker.js';
import type { RequestHandler } from './$types';
export const POST: RequestHandler = async ({ params, request, locals }) => {
if (!locals.user || locals.user.role !== 'admin') return json({ error: 'Administrator access is required.' }, { status: 403 });
let body: Record<string, unknown>;
try { body = await authBody(request); } catch (error) { return authError(error); }
if (body.confirmed !== true) return json({ error: 'Confirm the admin override before continuing.' }, { status: 400 });
const result = enableSafetyOverride(params.id, locals.user);
if (!result.ok) return json({ error: result.error }, { status: 409 });
void kickProvisioning();
return json({ ok: true }, { status: 202 });
};