forked from fahrPool/fahrPool
fix: add defense-in-depth role check to createOrtUndAuswaehlen
This commit is contained in:
parent
69c22f9afe
commit
e55ab12c2b
|
|
@ -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<void> {
|
||||
const abholortId = formData.get("abholort_id");
|
||||
|
|
@ -47,6 +48,14 @@ export async function createAuftrag(formData: FormData): Promise<void> {
|
|||
}
|
||||
|
||||
export async function createOrtUndAuswaehlen(ziel: "abholort" | "zielort", formData: FormData): Promise<void> {
|
||||
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");
|
||||
|
|
|
|||
Loading…
Reference in New Issue