OAuth implemented
This commit is contained in:
committed by
GitHub
parent
8cb07ae079
commit
1f0ecd696d
+24
-3
@@ -1,15 +1,36 @@
|
||||
import { Image, Text, View } from "react-native";
|
||||
import { useOAuth } from "@clerk/clerk-expo";
|
||||
import { useCallback } from "react";
|
||||
import { Alert, Image, Text, View } from "react-native";
|
||||
|
||||
import { icons } from "@/constants";
|
||||
|
||||
import { CustomButton } from "./custom-button";
|
||||
import { googleOAuth } from "@/lib/auth";
|
||||
import { router } from "expo-router";
|
||||
|
||||
type OAuthProps = {
|
||||
title: string;
|
||||
};
|
||||
|
||||
export const OAuth = ({ title }: OAuthProps) => {
|
||||
const handleGoogleSignIn = () => {};
|
||||
const { startOAuthFlow } = useOAuth({ strategy: "oauth_google" });
|
||||
|
||||
const handleGoogleOAuth = useCallback(async () => {
|
||||
try {
|
||||
const result = await googleOAuth(startOAuthFlow);
|
||||
|
||||
if (result?.code === "session_exists") {
|
||||
router.replace("/(root)/(tabs)/home");
|
||||
}
|
||||
|
||||
Alert.alert(
|
||||
result?.success ? "Success" : "Error",
|
||||
result?.message || "You are Logged In!",
|
||||
);
|
||||
} catch (err) {
|
||||
console.error("OAuth error", err);
|
||||
}
|
||||
}, [startOAuthFlow]);
|
||||
|
||||
return (
|
||||
<View>
|
||||
@@ -34,7 +55,7 @@ export const OAuth = ({ title }: OAuthProps) => {
|
||||
)}
|
||||
bgVariant="outline"
|
||||
textVariant="primary"
|
||||
onPress={handleGoogleSignIn}
|
||||
onPress={handleGoogleOAuth}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user