- Klick auf den Benutzernamen im Header (Kantinen- und Admin-Bereich) öffnet /konto - Name-Änderung per RLS-Policy mit spaltenscharfem Grant (nur full_name), Rolle bleibt ausschließlich über die Admin-API änderbar - E-Mail-Änderung über supabase.auth.updateUser mit Bestätigungslink; Trigger synchronisiert profiles.email nach Bestätigung - Passwortänderung verlangt zur Verifizierung das aktuelle Passwort (Re-Login-Check) plus Wiederholung des neuen Passworts - Passkey-Verwaltung aus /intern/konto hierher verschoben
65 lines
2.1 KiB
TypeScript
65 lines
2.1 KiB
TypeScript
import Link from "next/link";
|
|
import { redirect } from "next/navigation";
|
|
import { createClient } from "@/lib/supabase/server";
|
|
|
|
export default async function InternLayout({
|
|
children,
|
|
}: {
|
|
children: React.ReactNode;
|
|
}) {
|
|
const supabase = await createClient();
|
|
const {
|
|
data: { user },
|
|
} = await supabase.auth.getUser();
|
|
if (!user) redirect("/login");
|
|
|
|
const { data: profile } = await supabase
|
|
.from("profiles")
|
|
.select("role, full_name")
|
|
.eq("id", user.id)
|
|
.single();
|
|
if (!profile || !["staff", "admin"].includes(profile.role)) redirect("/");
|
|
|
|
return (
|
|
<div className="flex-1 flex flex-col">
|
|
<header className="bg-[var(--c-primary-dark)] text-white">
|
|
<div className="max-w-[1600px] mx-auto w-full px-4 py-3 flex flex-wrap items-center gap-x-5 gap-y-2">
|
|
<span className="font-bold">Kantinen-Bereich</span>
|
|
<nav className="flex flex-wrap gap-x-4 gap-y-1 text-sm">
|
|
<Link href="/intern" className="hover:underline">
|
|
Wochenplan
|
|
</Link>
|
|
<Link href="/intern/gerichte" className="hover:underline">
|
|
Gerichte
|
|
</Link>
|
|
<Link href="/intern/kennzeichnung" className="hover:underline">
|
|
Allergene & Zusatzstoffe
|
|
</Link>
|
|
{profile.role === "admin" && (
|
|
<Link href="/admin" className="hover:underline">
|
|
Verwaltung
|
|
</Link>
|
|
)}
|
|
<Link href="/" className="hover:underline">
|
|
Zur Speisekarte
|
|
</Link>
|
|
</nav>
|
|
<div className="ml-auto flex items-center gap-3 text-sm">
|
|
<Link href="/konto" className="text-white/70 hover:underline">
|
|
{profile.full_name || user.email}
|
|
</Link>
|
|
<form action="/logout" method="post">
|
|
<button type="submit" className="btn btn-del">
|
|
Abmelden
|
|
</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</header>
|
|
<main className="max-w-[1600px] mx-auto w-full px-4 py-6 flex-1">
|
|
{children}
|
|
</main>
|
|
</div>
|
|
);
|
|
}
|