diff --git a/src/pages/OnboardingPage.tsx b/src/pages/OnboardingPage.tsx index 0866b01..f5dd14f 100644 --- a/src/pages/OnboardingPage.tsx +++ b/src/pages/OnboardingPage.tsx @@ -218,17 +218,26 @@ export const OnboardingPage: React.FC = () => { } setStep1Loading(true); try { - // Real-time backend OTP verification call + // Real-time backend OTP verification call with strict validation const res = await api.verifyOtp('phone', enteredOtp); if (res && res.verified) { updateOnboarding({ isOtpVerified: true, phone: cleanPhone }); handleNext(); } else { - setStep1Error(res?.error || 'Invalid OTP. Please try again.'); + setStep1Error(res?.error || 'Invalid or expired OTP code. Please enter the latest OTP received.'); + setStep1Otp(['', '', '', '', '', '']); + setTimeout(() => { + document.getElementById('step1-otp-0')?.focus(); + }, 300); } } catch (otpErr: any) { - console.warn('OTP verification exception:', otpErr); - setStep1Error(otpErr?.message || 'Invalid OTP. Please try again.'); + console.warn('Strict OTP verification failed:', otpErr); + const msg = otpErr?.message || 'Invalid or expired OTP code. Please enter the latest OTP received.'; + setStep1Error(msg); + setStep1Otp(['', '', '', '', '', '']); + setTimeout(() => { + document.getElementById('step1-otp-0')?.focus(); + }, 300); } finally { setStep1Loading(false); }