'use client' import { useState } from 'react' import Link from 'next/link' import { createClient } from '@/lib/supabase/client' export default function ForgotPasswordPage() { const [email, setEmail] = useState('') const [loading, setLoading] = useState(false) const [submitted, setSubmitted] = useState(false) const [error, setError] = useState(null) async function handleSubmit(e: React.FormEvent) { e.preventDefault() if (!email) return setLoading(true) setError(null) const supabase = createClient() const appUrl = process.env.NEXT_PUBLIC_APP_URL ?? '' const redirectTo = `${appUrl}/api/auth/callback?next=/reset-password` const { error: resetError } = await supabase.auth.resetPasswordForEmail(email, { redirectTo, }) setLoading(false) if (resetError) { setError('Something went wrong. Please try again.') return } // Always show success — never reveal whether email exists setSubmitted(true) } if (submitted) { return (

Check your email

If an account exists for {email}, a password reset link has been sent.

Back to sign in
) } return (

Reset password

Enter your email and we'll send a reset link.

{error && (

{error}

)} setEmail(e.target.value)} required autoComplete="email" className="border border-gray-300 rounded-md px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500" />

Back to sign in

) }