feat: add auth to tui
This commit is contained in:
@@ -45,6 +45,7 @@ export default function RootLayout() {
|
||||
<Stack>
|
||||
<Stack.Protected guard={!isPending && !!session}>
|
||||
<Stack.Screen name="[...route]" options={{ headerShown: false }} />
|
||||
<Stack.Screen name="approve" />
|
||||
</Stack.Protected>
|
||||
<Stack.Protected guard={!isPending && !session}>
|
||||
<Stack.Screen name="auth" />
|
||||
|
||||
23
apps/expo/app/approve.tsx
Normal file
23
apps/expo/app/approve.tsx
Normal file
@@ -0,0 +1,23 @@
|
||||
import { authClient } from "@/lib/auth-client";
|
||||
import { useLocalSearchParams } from "expo-router";
|
||||
import { useEffect } from "react";
|
||||
import { Text } from "react-native";
|
||||
|
||||
export default function Page() {
|
||||
const { code } = useLocalSearchParams<{code: string }>();
|
||||
const { isPending, data } = authClient.useSession();
|
||||
if (isPending) return <Text>Loading...</Text>;
|
||||
if (!isPending && !data) return <Text>Please log in</Text>;
|
||||
|
||||
useEffect(() => {
|
||||
authClient.device.approve({
|
||||
userCode: code,
|
||||
});
|
||||
|
||||
}, []);
|
||||
|
||||
return <Text>
|
||||
Approving: {code}
|
||||
</Text>
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { createAuthClient } from "better-auth/react";
|
||||
import { genericOAuthClient } from "better-auth/client/plugins";
|
||||
import { deviceAuthorizationClient, genericOAuthClient } from "better-auth/client/plugins";
|
||||
import { expoClient } from "@better-auth/expo/client";
|
||||
import * as SecureStore from "expo-secure-store";
|
||||
import { BASE_URL } from "@money/shared";
|
||||
@@ -13,5 +13,6 @@ export const authClient = createAuthClient({
|
||||
storage: SecureStore,
|
||||
}),
|
||||
genericOAuthClient(),
|
||||
deviceAuthorizationClient(),
|
||||
]
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user