import { useState } from 'react'; import { Link } from 'react-router'; import { Wordmark } from '../components/Logo'; import { Button } from '../components/ui/button'; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '../components/ui/card'; import { Input } from '../components/ui/input'; import { supabase } from '../lib/supabase'; export default function ForgotPassword() { const [email, setEmail] = useState(''); const [error, setError] = useState(''); const [success, setSuccess] = useState(false); const [loading, setLoading] = useState(false); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setError(''); setLoading(true); try { const { error } = await supabase.auth.resetPasswordForEmail(email, { redirectTo: `${window.location.origin}/reset-password`, }); if (error) throw error; // Always show success to prevent email enumeration setSuccess(true); } catch (_err) { // Show generic message to prevent email enumeration setError('Unable to send reset email. Please try again later.'); } finally { setLoading(false); } }; return (
{/* Header */}
{/* Main content */}
Reset password {success ? 'Check your email for a reset link' : "Enter your email and we'll send you a reset link"} {success ? (
If an account exists with that email, you'll receive a password reset link shortly.

Didn't receive an email?{' '}

) : (
{error && (
{error}
)} setEmail(e.target.value)} required autoFocus />
)}

Remember your password?{' '} Sign in

); }