mirror of
https://github.com/Dvorinka/Containr.git
synced 2026-10-28 07:41:27 +00:00
Merge pull request #35 from Dvorinka/fix/mobile-auth-gate
fix(mobile): gate authed routes — cold-start redbox fix
This commit is contained in:
2 files changed
+13
-7
No files matched your search
@@ -19,10 +19,11 @@ function AuthGate() {
|
||||
useEffect(() => {
|
||||
if (!ready) return;
|
||||
const inLogin = segments[0] === 'login';
|
||||
if (!api && !inLogin) router.replace('/login');
|
||||
else if (api && inLogin) router.replace('/');
|
||||
if (api && inLogin) router.replace('/');
|
||||
}, [ready, api, segments, router]);
|
||||
|
||||
if (!ready) return null;
|
||||
|
||||
return (
|
||||
<Stack
|
||||
screenOptions={{
|
||||
@@ -31,11 +32,13 @@ function AuthGate() {
|
||||
contentStyle: { backgroundColor: colors.bg },
|
||||
}}
|
||||
>
|
||||
<Stack.Protected guard={!!api}>
|
||||
<Stack.Screen name="(tabs)" options={{ headerShown: false }} />
|
||||
<Stack.Screen name="project/[id]" options={{ title: 'Project' }} />
|
||||
<Stack.Screen name="service/[id]" options={{ title: 'Service' }} />
|
||||
<Stack.Screen name="service/logs" options={{ title: 'Logs' }} />
|
||||
</Stack.Protected>
|
||||
<Stack.Screen name="login" options={{ headerShown: false }} />
|
||||
<Stack.Screen name="(tabs)" options={{ headerShown: false }} />
|
||||
<Stack.Screen name="project/[id]" options={{ title: 'Project' }} />
|
||||
<Stack.Screen name="service/[id]" options={{ title: 'Service' }} />
|
||||
<Stack.Screen name="service/logs" options={{ title: 'Logs' }} />
|
||||
</Stack>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import { Redirect } from 'expo-router';
|
||||
import { useSession } from '../session';
|
||||
|
||||
export default function Index() {
|
||||
return <Redirect href="/(tabs)" />;
|
||||
const { ready, api } = useSession();
|
||||
if (!ready) return null;
|
||||
return <Redirect href={api ? '/(tabs)' : '/login'} />;
|
||||
}
|
||||
Reference in new issue
Block a user