From b81af0f6c6a28313adf3b754b8894fa693e0229c Mon Sep 17 00:00:00 2001 From: Meik Date: Fri, 16 Jan 2026 23:07:13 +0100 Subject: [PATCH] Aktueller Stand --- app/api/settings/registration/route.ts | 10 +++ app/login/page.tsx | 30 +++++++-- app/register/page.tsx | 87 +++++++++++++++++--------- 3 files changed, 95 insertions(+), 32 deletions(-) create mode 100644 app/api/settings/registration/route.ts diff --git a/app/api/settings/registration/route.ts b/app/api/settings/registration/route.ts new file mode 100644 index 0000000..bfbf70e --- /dev/null +++ b/app/api/settings/registration/route.ts @@ -0,0 +1,10 @@ +import { NextResponse } from "next/server"; +import { prisma } from "../../../../lib/prisma"; + +export async function GET() { + const setting = await prisma.setting.findUnique({ + where: { key: "registration_enabled" } + }); + const registrationEnabled = setting?.value !== "false"; + return NextResponse.json({ registrationEnabled }); +} diff --git a/app/login/page.tsx b/app/login/page.tsx index b299717..add4173 100644 --- a/app/login/page.tsx +++ b/app/login/page.tsx @@ -3,12 +3,29 @@ import { signIn } from "next-auth/react"; import Link from "next/link"; import { useRouter } from "next/navigation"; -import { useState } from "react"; +import { useEffect, useState } from "react"; export default function LoginPage() { const router = useRouter(); const [error, setError] = useState(null); const [showVerifyLink, setShowVerifyLink] = useState(false); + const [registrationEnabled, setRegistrationEnabled] = useState( + null + ); + + useEffect(() => { + const loadRegistration = async () => { + try { + const response = await fetch("/api/settings/registration"); + if (!response.ok) return; + const payload = await response.json(); + setRegistrationEnabled(payload.registrationEnabled !== false); + } catch { + setRegistrationEnabled(true); + } + }; + loadRegistration(); + }, []); const onSubmit = async (event: React.FormEvent) => { event.preventDefault(); @@ -78,9 +95,14 @@ export default function LoginPage() { {error &&

{error}

} -

- Kein Konto? Registrieren -

+ {registrationEnabled !== false && ( +

+ Kein Konto?{" "} + + Registrieren + +

+ )}

Passwort vergessen?{" "} diff --git a/app/register/page.tsx b/app/register/page.tsx index 8288bcf..73c88a7 100644 --- a/app/register/page.tsx +++ b/app/register/page.tsx @@ -2,11 +2,28 @@ import Link from "next/link"; import { signIn } from "next-auth/react"; -import { useState } from "react"; +import { useEffect, useState } from "react"; export default function RegisterPage() { const [error, setError] = useState(null); const [done, setDone] = useState(false); + const [registrationEnabled, setRegistrationEnabled] = useState( + null + ); + + useEffect(() => { + const loadRegistration = async () => { + try { + const response = await fetch("/api/settings/registration"); + if (!response.ok) return; + const payload = await response.json(); + setRegistrationEnabled(payload.registrationEnabled !== false); + } catch { + setRegistrationEnabled(true); + } + }; + loadRegistration(); + }, []); const onSubmit = async (event: React.FormEvent) => { event.preventDefault(); @@ -45,33 +62,47 @@ export default function RegisterPage() {

Erstelle ein Konto, um Termine vorzuschlagen und eigene Ansichten anzulegen.

-
- - - - -
- {done &&

Account erstellt.

} - {error &&

{error}

} + {registrationEnabled === false ? ( +
+ Registrierung ist derzeit deaktiviert. +
+ ) : registrationEnabled === null ? ( +

+ Registrierung wird geladen... +

+ ) : ( + <> +
+ + + + +
+ {done && ( +

Account erstellt.

+ )} + {error &&

{error}

} + + )}

Schon registriert? Login