mirror of
https://github.com/Dvorinka/Containr.git
synced 2026-10-28 15:51:26 +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(() => {
|
useEffect(() => {
|
||||||
if (!ready) return;
|
if (!ready) return;
|
||||||
const inLogin = segments[0] === 'login';
|
const inLogin = segments[0] === 'login';
|
||||||
if (!api && !inLogin) router.replace('/login');
|
if (api && inLogin) router.replace('/');
|
||||||
else if (api && inLogin) router.replace('/');
|
|
||||||
}, [ready, api, segments, router]);
|
}, [ready, api, segments, router]);
|
||||||
|
|
||||||
|
if (!ready) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack
|
<Stack
|
||||||
screenOptions={{
|
screenOptions={{
|
||||||
@@ -31,11 +32,13 @@ function AuthGate() {
|
|||||||
contentStyle: { backgroundColor: colors.bg },
|
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="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>
|
</Stack>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
import { Redirect } from 'expo-router';
|
import { Redirect } from 'expo-router';
|
||||||
|
import { useSession } from '../session';
|
||||||
|
|
||||||
export default function Index() {
|
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