From e55ab12c2b1b9e150984dba673fe99d66908a47f Mon Sep 17 00:00:00 2001 From: Jonny Date: Tue, 7 Jul 2026 09:13:29 +0200 Subject: [PATCH] fix: add defense-in-depth role check to createOrtUndAuswaehlen --- web/app/auftraege/neu/actions.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/web/app/auftraege/neu/actions.ts b/web/app/auftraege/neu/actions.ts index 08875d3..11d43e9 100644 --- a/web/app/auftraege/neu/actions.ts +++ b/web/app/auftraege/neu/actions.ts @@ -4,6 +4,7 @@ import { redirect } from "next/navigation"; import { createClient } from "@/lib/supabase/server"; import { validateOrt } from "@/lib/orte-fahrzeuge/validate-ort"; import { insertOrt } from "@/lib/orte-fahrzeuge/mutations"; +import { loadProfile } from "@/lib/auth/profile"; export async function createAuftrag(formData: FormData): Promise { const abholortId = formData.get("abholort_id"); @@ -47,6 +48,14 @@ export async function createAuftrag(formData: FormData): Promise { } export async function createOrtUndAuswaehlen(ziel: "abholort" | "zielort", formData: FormData): Promise { + const profileResult = await loadProfile(); + if ( + profileResult.status !== "ok" || + (profileResult.profile.role !== "admin" && profileResult.profile.role !== "disponent") + ) { + redirect(`/auftraege?error=${encodeURIComponent("Nur Disponent/Admin duerfen Auftraege anlegen.")}`); + } + const vorgaengerAuftragId = formData.get("vorgaenger_auftrag_id"); const abholortId = formData.get("abholort_id"); const zielortId = formData.get("zielort_id");