- 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
45 lines
1.4 KiB
TypeScript
45 lines
1.4 KiB
TypeScript
import { redirect } from "next/navigation";
|
|
import Link from "next/link";
|
|
import { createClient } from "@/lib/supabase/server";
|
|
import AccountManager from "@/components/AccountManager";
|
|
|
|
export default async function KontoPage() {
|
|
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">Mein Konto</span>
|
|
<nav className="ml-auto flex flex-wrap gap-x-4 gap-y-1 text-sm">
|
|
<Link
|
|
href={profile.role === "admin" ? "/admin" : "/intern"}
|
|
className="hover:underline"
|
|
>
|
|
← Zurück
|
|
</Link>
|
|
</nav>
|
|
</div>
|
|
</header>
|
|
<main className="max-w-[1600px] mx-auto w-full px-4 py-6 flex-1">
|
|
<AccountManager
|
|
role={profile.role}
|
|
initialFullName={profile.full_name ?? ""}
|
|
initialEmail={user.email ?? ""}
|
|
/>
|
|
</main>
|
|
</div>
|
|
);
|
|
}
|