From 28d98cd7909282fc4cc5bb8ec9c2c66e93c98ec7 Mon Sep 17 00:00:00 2001 From: Kakabay <2kakabayashyrberdyew@gmail.com> Date: Thu, 9 Jan 2025 17:36:40 +0500 Subject: [PATCH] auth fix with new api modifications. --- components/lottery/auth/ProtectedRoute.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/components/lottery/auth/ProtectedRoute.tsx b/components/lottery/auth/ProtectedRoute.tsx index 76cdb05..b40deab 100644 --- a/components/lottery/auth/ProtectedRoute.tsx +++ b/components/lottery/auth/ProtectedRoute.tsx @@ -17,8 +17,13 @@ const ProtectedRoute = ({ children }: { children: React.ReactNode }) => { try { // Try to authenticate with stored credentials const response = await Queries.authenticateLottery(phone, code); - setAuth(response, phone, code); - setIsLoading(false); + + if (response.errorMessage) { + router.replace('/lottery/auth'); + } else { + setAuth(response, phone, code); + setIsLoading(false); + } return; // Exit early if authentication successful } catch (err) { console.error('Authentication failed:', err);