import { createSignal, Show } from 'solid-js'; import { useNavigate, useLocation } from '@solidjs/router'; import AuthLayout from '@/app/auth/components/AuthLayout'; import { SubmitButton, ErrorMessage } from '@/app/auth/components/FormElements'; import { AuthService } from '@/client'; import { ApiError } from '@/client/core/ApiError'; function ArrowLeft(props: { size: number }) { return ( ); } function Envelope(props: { size: number; color: string }) { return ( ); } export default function ForgotPassword() { const navigate = useNavigate(); const location = useLocation(); const [email, setEmail] = createSignal(''); const [error, setError] = createSignal(''); const [loading, setLoading] = createSignal(false); const isSent = () => location.hash === '#sent'; function setStepSent() { navigate('/forgot-password#sent', { replace: true }); } function setStepForm() { navigate('/forgot-password', { replace: true }); } async function handleSubmit(e: SubmitEvent) { e.preventDefault(); if (loading()) return; setError(''); if (!email().trim()) { setError('Please enter your email'); return; } const emailRe = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; if (!emailRe.test(email().trim())) { setError('Invalid email format'); return; } setLoading(true); try { await AuthService.authRequestPasswordReset({ requestBody: { email: email().trim() } }); setStepSent(); } catch (err) { if (err instanceof ApiError && err.status === 429) { setError('Too many requests, please try again later'); } else { setError('Unable to request password reset, please try again'); } } finally { setLoading(false); } } return ( Email Sent If {email() || 'the email address'} is registered, you will receive a password reset email. Please check your inbox and spam folder. The link is valid for 1 hour. Back to Sign In { setStepForm(); setError(''); }}>Change email } > Forgot Password Enter your registered email to receive a password reset link. {error() && {error()}} Email setEmail(e.currentTarget.value)} autofocus /> Send Reset Link Back to Sign In ); }
If {email() || 'the email address'} is registered, you will receive a password reset email.
Please check your inbox and spam folder. The link is valid for 1 hour.
Enter your registered email to receive a password reset link.