Skip to content

Commit 937e7d2

Browse files
feat: Add password confirmation field and error handling to Reset Password page
1 parent 905e1d1 commit 937e7d2

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

Diff for: app/auth/reset-password/page.tsx

+23-1
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,19 @@ import { supabase } from '@/lib/supabaseClient'
1010
export default function ResetPasswordPage() {
1111
const router = useRouter()
1212
const [newPassword, setNewPassword] = useState('')
13+
const [confirmPassword, setConfirmPassword] = useState('')
1314
const [status, setStatus] = useState<'idle' | 'updating' | 'updated' | 'error'>('idle')
15+
const [errorMessage, setErrorMessage] = useState('')
1416

1517
const handleSubmit = async (e: React.FormEvent) => {
1618
e.preventDefault()
19+
setErrorMessage('')
20+
21+
if (newPassword !== confirmPassword) {
22+
setErrorMessage('Passwords do not match.')
23+
return
24+
}
25+
1726
setStatus('updating')
1827

1928
// Use the access token to update the user's password
@@ -47,6 +56,19 @@ export default function ResetPasswordPage() {
4756
required
4857
className="w-full p-2 border rounded"
4958
/>
59+
<input
60+
type="password"
61+
placeholder="Confirm Password"
62+
value={confirmPassword}
63+
onChange={(e) => setConfirmPassword(e.target.value)}
64+
required
65+
className="w-full p-2 border rounded"
66+
/>
67+
{errorMessage && (
68+
<Alert variant="destructive" className="mt-2">
69+
<AlertDescription>{errorMessage}</AlertDescription>
70+
</Alert>
71+
)}
5072
<Button type="submit" disabled={status === 'updating'}>
5173
{status === 'updating' ? 'Updating...' : 'Set New Password'}
5274
</Button>
@@ -65,4 +87,4 @@ export default function ResetPasswordPage() {
6587
</Card>
6688
</main>
6789
)
68-
}
90+
}

0 commit comments

Comments
 (0)