'use client' import { useState } from 'react' import { signIn } from 'next-auth/react' import { Button } from '@/components/ui/button' import { Input } from '@/components/ui/input' import { Shield, Mail, Lock } from 'lucide-react' import { BrandIcon } from '@/components/brand-icon' import Link from 'next/link' import { toast } from 'sonner' import { useRouter } from 'next/navigation' export function LoginClient({ oidcEnabled, passwordEnabled }: { oidcEnabled: boolean; passwordEnabled: boolean }) { const [email, setEmail] = useState('') const [password, setPassword] = useState('') const [loading, setLoading] = useState(false) const router = useRouter() const handleEmailLogin = async (e: React.FormEvent) => { e.preventDefault() setLoading(true) try { // signIn with redirect:false still rejects on network failures. const result = await signIn('credentials', { email, password, redirect: false }) if (result?.ok) { router.push('/pages') } else if (result?.code === 'throttled') { // Review M-8: Go's 429 is propagated as a CredentialsSignin code; // do not present throttling as a wrong password. toast.error('Too many attempts. Wait a few minutes and try again.') } else { toast.error('Invalid credentials') } } catch { toast.error('Sign-in failed; check your connection') } finally { setLoading(false) } } return (

Superbrain

Your personal binder of life on the web

{!oidcEnabled && passwordEnabled && (

Authelia single sign-on is not configured. Use email below.

)} {!oidcEnabled && !passwordEnabled && (

This server is configured for Authelia single sign-on only, but the OIDC variables are missing or placeholders. Ask the operator to check AUTH_MODE / OIDC_* configuration.

)} {passwordEnabled && ( <>
or continue with email
) => setEmail(e.target.value)} className="pl-10" required />
) => setPassword(e.target.value)} className="pl-10" required />
Forgot password?

Don't have an account? Sign up

)}

Help center

) }