import type { Metadata } from "next"; import { redirect } from "next/navigation"; import { Logo } from "@/components/SiteHeader"; import { ZodiacWheel } from "@/components/ZodiacWheel"; import { BACKEND_URL, getMe } from "@/lib/server"; import type { PublicConfig } from "@/lib/types"; import { GoogleLogin } from "./GoogleLogin"; export const metadata: Metadata = { title: "Belépés" }; /** Only local paths, so the login cannot redirect to another site. */ function safeTarget(value: string | string[] | undefined): string { const v = Array.isArray(value) ? value[0] : value; return v && v.startsWith("/") && !v.startsWith("//") ? v : "/profil"; } async function loadConfig(): Promise { try { const res = await fetch(`${BACKEND_URL}/v1/config`, { cache: "no-store" }); return res.ok ? ((await res.json()) as PublicConfig) : null; } catch { return null; } } export default async function LoginPage({ searchParams }: { searchParams: Promise> }) { const target = safeTarget((await searchParams).vissza); if (await getMe()) redirect(target); const config = await loadConfig(); const clientId = config?.google_login.enabled ? config.google_login.client_id : null; return (

Belépés

Lépj be a Google-fiókoddal. Ha még nincs fiókod, az első belépéskor létrejön.

{config === null ? (

A szerver most nem érhető el. Próbáld újra egy kicsit később.

) : clientId ? ( ) : (

A Google-belépés még nincs beállítva (a backend GOOGLE_CLIENT_IDS változója üres).

)}

A belépéssel elfogadod, hogy a születési adataidat a képleted kiszámításához tároljuk. Bármikor törölheted őket a profilodban.

); }