forked from cardosofelipe/fast-next-template
Add timeout cleanup to password reset confirm page and improve accessibility attributes
- Added `useEffect` for proper timeout cleanup in `PasswordResetConfirmForm` to prevent memory leaks during unmount. - Enhanced form accessibility by adding `aria-required` attributes to all required fields for better screen reader compatibility. - Updated `IMPLEMENTATION_PLAN.md` to reflect completion of Password Reset Flow and associated quality metrics.
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
'use client';
|
||||
|
||||
import { useSearchParams, useRouter } from 'next/navigation';
|
||||
import { useEffect, useRef } from 'react';
|
||||
import { PasswordResetConfirmForm } from '@/components/auth/PasswordResetConfirmForm';
|
||||
import { Alert } from '@/components/ui/alert';
|
||||
import Link from 'next/link';
|
||||
@@ -14,11 +15,21 @@ export default function PasswordResetConfirmPage() {
|
||||
const searchParams = useSearchParams();
|
||||
const router = useRouter();
|
||||
const token = searchParams.get('token');
|
||||
const timeoutRef = useRef<NodeJS.Timeout | null>(null);
|
||||
|
||||
// Cleanup timeout on unmount
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
if (timeoutRef.current) {
|
||||
clearTimeout(timeoutRef.current);
|
||||
}
|
||||
};
|
||||
}, []);
|
||||
|
||||
// Handle successful password reset
|
||||
const handleSuccess = () => {
|
||||
// Wait 3 seconds then redirect to login
|
||||
setTimeout(() => {
|
||||
timeoutRef.current = setTimeout(() => {
|
||||
router.push('/login');
|
||||
}, 3000);
|
||||
};
|
||||
|
||||
@@ -210,6 +210,7 @@ export function PasswordResetConfirmForm({
|
||||
? 'new-password-error'
|
||||
: 'password-requirements'
|
||||
}
|
||||
aria-required="true"
|
||||
/>
|
||||
{form.formState.errors.new_password && (
|
||||
<p id="new-password-error" className="text-sm text-destructive">
|
||||
@@ -284,6 +285,7 @@ export function PasswordResetConfirmForm({
|
||||
? 'confirm-password-error'
|
||||
: undefined
|
||||
}
|
||||
aria-required="true"
|
||||
/>
|
||||
{form.formState.errors.confirm_password && (
|
||||
<p id="confirm-password-error" className="text-sm text-destructive">
|
||||
|
||||
@@ -157,6 +157,7 @@ export function PasswordResetRequestForm({
|
||||
{...form.register('email')}
|
||||
aria-invalid={!!form.formState.errors.email}
|
||||
aria-describedby={form.formState.errors.email ? 'email-error' : undefined}
|
||||
aria-required="true"
|
||||
/>
|
||||
{form.formState.errors.email && (
|
||||
<p id="email-error" className="text-sm text-destructive">
|
||||
|
||||
Reference in New Issue
Block a user