Merge branch 'codex/fix-public-landing-clean'
This commit is contained in:
+1
-1
@@ -16,7 +16,7 @@ const geistMono = Geist_Mono({
|
|||||||
|
|
||||||
export const metadata: Metadata = {
|
export const metadata: Metadata = {
|
||||||
metadataBase: new URL(
|
metadataBase: new URL(
|
||||||
process.env.NEXT_PUBLIC_SITE_URL ?? "https://kita-planer.example.com",
|
process.env.NEXT_PUBLIC_SITE_URL ?? "https://mein-kitaplaner.de",
|
||||||
),
|
),
|
||||||
title: {
|
title: {
|
||||||
default: "Der digitale Kita-Planer für Elternvereine",
|
default: "Der digitale Kita-Planer für Elternvereine",
|
||||||
|
|||||||
+4
-10
@@ -1,7 +1,6 @@
|
|||||||
import type { Metadata } from "next";
|
import type { Metadata } from "next";
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { redirect } from "next/navigation";
|
|
||||||
import {
|
import {
|
||||||
ArrowRight,
|
ArrowRight,
|
||||||
CheckCircle2,
|
CheckCircle2,
|
||||||
@@ -23,8 +22,6 @@ import {
|
|||||||
UsersRound,
|
UsersRound,
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
|
|
||||||
import { auth } from "@/auth";
|
|
||||||
import { getPostLoginRedirect } from "@/lib/post-login-redirect";
|
|
||||||
import { Badge } from "@/components/ui/badge";
|
import { Badge } from "@/components/ui/badge";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import {
|
import {
|
||||||
@@ -41,6 +38,9 @@ export const metadata: Metadata = {
|
|||||||
title: "Kita-Planer für Elterninitiativen und Kita-Vereine",
|
title: "Kita-Planer für Elterninitiativen und Kita-Vereine",
|
||||||
description:
|
description:
|
||||||
"Die einfache Plattform für Elterninitiativen, freie Kitas und Kita-Vereine: organisiert Dienste, Termine, Krankmeldungen und offizielle Kommunikation an einem Ort.",
|
"Die einfache Plattform für Elterninitiativen, freie Kitas und Kita-Vereine: organisiert Dienste, Termine, Krankmeldungen und offizielle Kommunikation an einem Ort.",
|
||||||
|
alternates: {
|
||||||
|
canonical: "/",
|
||||||
|
},
|
||||||
openGraph: {
|
openGraph: {
|
||||||
title: "Kita-Planer für Elterninitiativen und Kita-Vereine",
|
title: "Kita-Planer für Elterninitiativen und Kita-Vereine",
|
||||||
description:
|
description:
|
||||||
@@ -172,13 +172,7 @@ const onboardingSteps = [
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
// Eingeloggte User von der Landingpage direkt weiterleiten.
|
export default function LandingPage() {
|
||||||
export default async function LandingPage() {
|
|
||||||
const session = await auth();
|
|
||||||
if (session?.user?.id) {
|
|
||||||
redirect(getPostLoginRedirect(session.user));
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="min-h-screen bg-[#f8faf8] text-slate-950">
|
<div className="min-h-screen bg-[#f8faf8] text-slate-950">
|
||||||
<header className="absolute left-0 right-0 top-0 z-20">
|
<header className="absolute left-0 right-0 top-0 z-20">
|
||||||
|
|||||||
+24
-4
@@ -14,14 +14,31 @@ import { auth } from "@/auth";
|
|||||||
// Eingeloggt + kein kitaId + nicht /onboarding → /onboarding
|
// Eingeloggt + kein kitaId + nicht /onboarding → /onboarding
|
||||||
// Eingeloggt + SUPERADMIN → /admin
|
// Eingeloggt + SUPERADMIN → /admin
|
||||||
// Eingeloggt + hat kitaId + auf /onboarding → /dashboard
|
// Eingeloggt + hat kitaId + auf /onboarding → /dashboard
|
||||||
// Eingeloggt + auf /login oder /register → /
|
// Eingeloggt + auf /login oder /register → Post-Login-Ziel
|
||||||
// =====================================================================
|
// =====================================================================
|
||||||
|
|
||||||
const ONBOARDING_ROUTE = "/onboarding";
|
const ONBOARDING_ROUTE = "/onboarding";
|
||||||
const PROTECTED_PREFIX = ["/dashboard", "/admin", "/onboarding"];
|
const PROTECTED_PREFIX = ["/dashboard", "/admin", "/onboarding"];
|
||||||
|
const PUBLIC_PATHS = new Set(["/", "/impressum", "/datenschutz"]);
|
||||||
|
const PUBLIC_PREFIX = ["/features"];
|
||||||
|
|
||||||
|
function getPostLoginPath(user: { role?: string; kitaId?: string | null }) {
|
||||||
|
if (user.role === "SUPERADMIN") {
|
||||||
|
return "/admin";
|
||||||
|
}
|
||||||
|
|
||||||
|
return user.kitaId ? "/dashboard" : ONBOARDING_ROUTE;
|
||||||
|
}
|
||||||
|
|
||||||
export async function proxy(request: NextRequest) {
|
export async function proxy(request: NextRequest) {
|
||||||
const { pathname } = request.nextUrl;
|
const { pathname } = request.nextUrl;
|
||||||
|
const isPublicRoute =
|
||||||
|
PUBLIC_PATHS.has(pathname) ||
|
||||||
|
PUBLIC_PREFIX.some((prefix) => pathname.startsWith(prefix));
|
||||||
|
|
||||||
|
if (isPublicRoute) {
|
||||||
|
return NextResponse.next();
|
||||||
|
}
|
||||||
|
|
||||||
// Auth.js liest den Session-JWT aus dem Cookie —
|
// Auth.js liest den Session-JWT aus dem Cookie —
|
||||||
// kein DB-Call, pure Token-Verifikation (Edge-sicher).
|
// kein DB-Call, pure Token-Verifikation (Edge-sicher).
|
||||||
@@ -43,10 +60,12 @@ export async function proxy(request: NextRequest) {
|
|||||||
|
|
||||||
// ── 2. Eingeloggt ───────────────────────────────────────────────────
|
// ── 2. Eingeloggt ───────────────────────────────────────────────────
|
||||||
if (hasValidUser && user) {
|
if (hasValidUser && user) {
|
||||||
// 2a. Eingeloggter User auf Login/Register-Seite → Startseite,
|
// 2a. Eingeloggter User auf Login/Register-Seite → direkt zum Ziel,
|
||||||
// die dann selbst zu /dashboard oder /onboarding redirectet.
|
// damit die öffentliche Startseite stabil indexierbar bleibt.
|
||||||
if (pathname === "/login" || pathname === "/register") {
|
if (pathname === "/login" || pathname === "/register") {
|
||||||
return NextResponse.redirect(new URL("/", request.nextUrl));
|
return NextResponse.redirect(
|
||||||
|
new URL(getPostLoginPath(user), request.nextUrl),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user.role === "SUPERADMIN" && pathname === ONBOARDING_ROUTE) {
|
if (user.role === "SUPERADMIN" && pathname === ONBOARDING_ROUTE) {
|
||||||
@@ -58,6 +77,7 @@ export async function proxy(request: NextRequest) {
|
|||||||
if (
|
if (
|
||||||
!user.kitaId &&
|
!user.kitaId &&
|
||||||
user.role !== "SUPERADMIN" &&
|
user.role !== "SUPERADMIN" &&
|
||||||
|
isProtectedRoute &&
|
||||||
!pathname.startsWith(ONBOARDING_ROUTE)
|
!pathname.startsWith(ONBOARDING_ROUTE)
|
||||||
) {
|
) {
|
||||||
return NextResponse.redirect(new URL(ONBOARDING_ROUTE, request.nextUrl));
|
return NextResponse.redirect(new URL(ONBOARDING_ROUTE, request.nextUrl));
|
||||||
|
|||||||
Reference in New Issue
Block a user