-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
129 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,21 @@ | ||
import * as React from "react"; | ||
import { SafeAreaView } from "react-native"; | ||
import { SignedIn, SignedOut, useAuth } from "@clerk/clerk-expo"; | ||
import { Text } from "tamagui"; | ||
|
||
export default function Auth() { | ||
return <Text>Auth</Text>; | ||
import SignInWithOAuth from "~/components/auth/SignInWithOAuth"; | ||
|
||
export default function AuthPage() { | ||
const auth = useAuth(); | ||
console.log("is signed in", auth.isSignedIn); | ||
return ( | ||
<SafeAreaView> | ||
<SignedIn> | ||
<Text>You are Signed in</Text> | ||
</SignedIn> | ||
<SignedOut> | ||
<SignInWithOAuth /> | ||
</SignedOut> | ||
</SafeAreaView> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import React from "react"; | ||
import { Button } from "react-native"; | ||
import * as WebBrowser from "expo-web-browser"; | ||
import { useOAuth } from "@clerk/clerk-expo"; | ||
|
||
import { useWarmUpBrowser } from "~/hooks/useWarmUpBrowser"; | ||
|
||
WebBrowser.maybeCompleteAuthSession(); | ||
|
||
const SignInWithOAuth = () => { | ||
// Warm up the android browser to improve UX | ||
// https://docs.expo.dev/guides/authentication/#improving-user-experience | ||
useWarmUpBrowser(); | ||
|
||
const { startOAuthFlow } = useOAuth({ strategy: "oauth_google" }); | ||
|
||
const onPress = React.useCallback(async () => { | ||
try { | ||
const { createdSessionId, signIn, signUp, setActive } = | ||
await startOAuthFlow(); | ||
|
||
if (createdSessionId && setActive) { | ||
await setActive({ session: createdSessionId }); // Await the setActive function call | ||
} else { | ||
// Use signIn or signUp for next steps such as MFA | ||
} | ||
} catch (err) { | ||
console.error("OAuth error", err); | ||
} | ||
}, []); | ||
|
||
return <Button title="Sign in with Google" onPress={onPress} />; | ||
}; | ||
export default SignInWithOAuth; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
import HamburgerMenu from "./HamburgerMenu"; | ||
import Logo from "./Logo"; | ||
import PinButton from "./PinButton"; | ||
import RestaurantTabs from "./RestaurantTabs"; | ||
|
||
export { HamburgerMenu, Logo, PinButton, RestaurantTabs }; | ||
export * from "./navigation/HamburgerMenu"; | ||
export * from "./Logo"; | ||
export * from "./PinButton"; | ||
export * from "./navigation/RestaurantTabs"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import React from "react"; | ||
import * as WebBrowser from "expo-web-browser"; | ||
|
||
export const useWarmUpBrowser = () => { | ||
React.useEffect(() => { | ||
void WebBrowser.warmUpAsync(); | ||
return () => { | ||
void WebBrowser.coolDownAsync(); | ||
}; | ||
}, []); | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.