Aktueller Stand
This commit is contained in:
@@ -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<string | null>(null);
|
||||
const [showVerifyLink, setShowVerifyLink] = useState(false);
|
||||
const [registrationEnabled, setRegistrationEnabled] = useState<boolean | null>(
|
||||
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<HTMLFormElement>) => {
|
||||
event.preventDefault();
|
||||
@@ -78,9 +95,14 @@ export default function LoginPage() {
|
||||
</button>
|
||||
</form>
|
||||
{error && <p className="mt-3 text-sm text-red-600">{error}</p>}
|
||||
<p className="mt-4 text-sm text-slate-600">
|
||||
Kein Konto? <Link href="/register" className="text-brand-700">Registrieren</Link>
|
||||
</p>
|
||||
{registrationEnabled !== false && (
|
||||
<p className="mt-4 text-sm text-slate-600">
|
||||
Kein Konto?{" "}
|
||||
<Link href="/register" className="text-brand-700">
|
||||
Registrieren
|
||||
</Link>
|
||||
</p>
|
||||
)}
|
||||
<p className="mt-2 text-sm text-slate-600">
|
||||
Passwort vergessen?{" "}
|
||||
<Link href="/reset" className="text-brand-700">
|
||||
|
||||
Reference in New Issue
Block a user