diff --git a/src/app/(mobile-ui)/home/page.tsx b/src/app/(mobile-ui)/home/page.tsx index cf4b7ad09..b4464dbb1 100644 --- a/src/app/(mobile-ui)/home/page.tsx +++ b/src/app/(mobile-ui)/home/page.tsx @@ -132,7 +132,7 @@ export default function Home() { // effect for showing balance warning modal useEffect(() => { - if (isFetchingBalance || balance === undefined) return + if (isFetchingBalance || balance === undefined || !user) return if (typeof window !== 'undefined') { const hasSeenBalanceWarning = getFromLocalStorage(`${user!.user.userId}-hasSeenBalanceWarning`) @@ -152,11 +152,11 @@ export default function Home() { setShowBalanceWarningModal(true) } } - }, [balance, isFetchingBalance, showIOSPWAInstallModal, showAddMoneyPromptModal]) + }, [balance, isFetchingBalance, showIOSPWAInstallModal, showAddMoneyPromptModal, user]) // effect for showing balance warning modal useEffect(() => { - if (isFetchingBalance || balance === undefined) return + if (isFetchingBalance || balance === undefined || !user) return if (typeof window !== 'undefined') { const hasSeenBalanceWarning = getFromLocalStorage(`${user!.user.userId}-hasSeenBalanceWarning`) @@ -175,7 +175,7 @@ export default function Home() { setShowBalanceWarningModal(true) } } - }, [balance, isFetchingBalance, showIOSPWAInstallModal, showAddMoneyPromptModal]) + }, [balance, isFetchingBalance, showIOSPWAInstallModal, showAddMoneyPromptModal, user]) // effect for showing add money prompt modal useEffect(() => { diff --git a/src/app/(mobile-ui)/layout.tsx b/src/app/(mobile-ui)/layout.tsx index fd2019b1b..33b0feb11 100644 --- a/src/app/(mobile-ui)/layout.tsx +++ b/src/app/(mobile-ui)/layout.tsx @@ -79,7 +79,14 @@ const Layout = ({ children }: { children: React.ReactNode }) => { // Allow access to public paths without authentication const isPublicPath = publicPathRegex.test(pathName) - if (!isReady || (isFetchingUser && !user && !hasToken && !isPublicPath)) { + // redirect to setup if user is not logged in + useEffect(() => { + if (!isFetchingUser && !user) { + router.push('/setup') + } + }, [user, isFetchingUser, router]) + + if (!isReady || !user || (isFetchingUser && !hasToken && !isPublicPath)) { return (