From e5620ddc86aa705b96dc9630d889882d152c1764 Mon Sep 17 00:00:00 2001 From: Gabriel Bianchi Date: Wed, 16 Oct 2024 18:47:15 -0300 Subject: [PATCH] Expo > Don't `router.replace()` on dismiss web view (#1079) Co-authored-by: dbianchii Co-authored-by: juliusmarminge --- apps/expo/src/utils/auth.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/apps/expo/src/utils/auth.tsx b/apps/expo/src/utils/auth.tsx index a2f9194f4..b1cf2a0f0 100644 --- a/apps/expo/src/utils/auth.tsx +++ b/apps/expo/src/utils/auth.tsx @@ -14,12 +14,14 @@ export const signIn = async () => { redirectTo, ); - if (result.type !== "success") return; + if (result.type !== "success") return false; const url = Linking.parse(result.url); const sessionToken = String(url.queryParams?.session_token); - if (!sessionToken) return; + if (!sessionToken) throw new Error("No session token found"); setToken(sessionToken); + + return true; }; export const useUser = () => { @@ -32,7 +34,9 @@ export const useSignIn = () => { const router = useRouter(); return async () => { - await signIn(); + const success = await signIn(); + if (!success) return; + await utils.invalidate(); router.replace("/"); };