'use client'; import { Suspense, useState, useEffect } from 'react'; import Link from 'next/link'; import { useRouter, useSearchParams } from 'next/navigation'; import Header from '@/components/Header'; import Footer from '@/components/Footer'; import { createClient } from '@/lib/supabase/client'; function safeNext(next: string | null): string { if (!next) return '/forum'; if (!next.startsWith('/') || next.startsWith('//')) return '/forum'; return next; } function ForumLoginInner() { const router = useRouter(); const params = useSearchParams(); const next = safeNext(params.get('next')); const supabase = createClient(); const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [error, setError] = useState(null); const [loading, setLoading] = useState(false); useEffect(() => { supabase.auth.getUser().then(({ data: { user } }) => { if (user) router.replace(next); }); }, [next, router, supabase]); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setError(null); if (!email || !password) { setError('Email and password are required.'); return; } setLoading(true); const { error: signInError } = await supabase.auth.signInWithPassword({ email, password }); setLoading(false); if (signInError) { setError(signInError.message); return; } window.location.href = next; }; return ( <>

Sign in to the Forum

Use your Broadcast Beat account to post, reply, and vote.

{error && (
{error}
)}
setEmail(e.target.value)} autoComplete="email" required className="w-full bg-[#0d0d0d] border border-[#2a2a2a] rounded-lg px-3 py-2 text-white font-body text-sm focus:outline-none focus:border-[#3b82f6]" />
setPassword(e.target.value)} autoComplete="current-password" required className="w-full bg-[#0d0d0d] border border-[#2a2a2a] rounded-lg px-3 py-2 text-white font-body text-sm focus:outline-none focus:border-[#3b82f6]" />
No account yet?{' '} Create one