auth fix with new api modifications.

This commit is contained in:
Kakabay 2025-01-09 17:36:40 +05:00
parent 4156c57015
commit 28d98cd790
1 changed files with 7 additions and 2 deletions

View File

@ -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);