Skip to content

Commit 5ebce9e

Browse files
committed
test auth
1 parent 74c7d59 commit 5ebce9e

File tree

8 files changed

+300
-4
lines changed

8 files changed

+300
-4
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ expo-env.d.ts
2121

2222
.env
2323
android
24-
android/*
24+
android/*
25+
keykey/*

app/(home)/user.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,21 @@
1+
// import GoogleLogin from "@/components/auth/GoogleLogin";
12
import SafeAreaWrapper from "@/components/SafeAreaWrapper";
23
import { CustomText } from "@/components/ui";
4+
import { tokenAtom } from "@/store/auth";
5+
import { useAtom, useAtomValue } from "jotai";
6+
import { TouchableOpacity } from "react-native-gesture-handler";
37

48
export default function AllAnime() {
9+
const [token, setToken] = useAtom(tokenAtom);
10+
511
return (
612
<SafeAreaWrapper>
713
<CustomText>All Anime</CustomText>
14+
15+
{/* {!token ? <GoogleLogin /> : <CustomText>Logged in</CustomText>} */}
16+
<TouchableOpacity>
17+
<CustomText>Sign Out</CustomText>
18+
</TouchableOpacity>
819
</SafeAreaWrapper>
920
);
1021
}

app/_layout.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,19 @@ import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
1515

1616
import { GestureHandlerRootView } from "react-native-gesture-handler";
1717
import { BottomSheetModalProvider } from "@gorhom/bottom-sheet";
18+
// import { GoogleSignin } from "@react-native-google-signin/google-signin";
1819

19-
// Prevent the splash screen from auto-hiding before asset loading is complete.
2020
SplashScreen.preventAutoHideAsync();
2121
ScreenOrientation.unlockAsync();
2222

2323
const queryClient = new QueryClient();
2424

2525
export default function RootLayout() {
26+
// GoogleSignin.configure({
27+
// scopes: ["https://www.googleapis.com/auth/drive.readonly"],
28+
// webClientId: process.env.EXPO_PUBLIC_GOOGLE_WEB_CLIENT_ID,
29+
// });
30+
2631
const [loaded, error] = useFonts({
2732
Poppins_400Regular,
2833
Poppins_600SemiBold,

components/auth/GoogleLogin.tsx

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
// import { View } from "react-native";
2+
// import { API_URL } from "@/constants/Strings";
3+
// import { axiosIn } from "@/utils/axios";
4+
// import { supabase } from "@/utils/supabase";
5+
// import {
6+
// GoogleSignin,
7+
// GoogleSigninButton,
8+
// statusCodes,
9+
// } from "@react-native-google-signin/google-signin";
10+
// import { Alert } from "react-native";
11+
// import { useSetAtom } from "jotai";
12+
// import { tokenAtom } from "@/store/auth";
13+
14+
// export default function GoogleLogin() {
15+
// const setToken = useSetAtom(tokenAtom);
16+
17+
// return (
18+
// <View>
19+
// <GoogleSigninButton
20+
// size={GoogleSigninButton.Size.Wide}
21+
// color={GoogleSigninButton.Color.Dark}
22+
// onPress={async () => {
23+
// try {
24+
// await GoogleSignin.hasPlayServices();
25+
// const userInfo = await GoogleSignin.signIn();
26+
// // console.log(userInfo);
27+
28+
// if (userInfo.idToken) {
29+
// const { data, error } = await supabase.auth.signInWithIdToken({
30+
// provider: "google",
31+
// token: userInfo.idToken,
32+
// });
33+
34+
// if (error) {
35+
// console.log("ERROR SUPABASE LOGIN: ", error);
36+
// Alert.alert("Error logging in with Supabase!");
37+
// } else {
38+
// const getToken = await axiosIn.post(
39+
// `${API_URL}/anime/auth/login`,
40+
// {
41+
// email: data.user.email,
42+
// },
43+
// {
44+
// headers: {
45+
// Authorization: `Bearer ${data.session.access_token}`,
46+
// },
47+
// }
48+
// );
49+
50+
// if (getToken.data && getToken.data.status == true) {
51+
// console.log("TOKEN: ", getToken.data);
52+
// setToken(getToken.data.data.token);
53+
// Alert.alert("Token found!");
54+
// } else {
55+
// console.log("NO TOKEN: ", getToken.data);
56+
// Alert.alert("No token found!");
57+
// }
58+
// }
59+
// } else {
60+
// throw new Error("no ID token present!");
61+
// }
62+
// } catch (error: any) {
63+
// console.log(error);
64+
// if (error.code === statusCodes.SIGN_IN_CANCELLED) {
65+
// // user cancelled the login flow
66+
// } else if (error.code === statusCodes.IN_PROGRESS) {
67+
// // operation (e.g. sign in) is in progress already
68+
// } else if (error.code === statusCodes.PLAY_SERVICES_NOT_AVAILABLE) {
69+
// // play services not available or outdated
70+
// } else {
71+
// // some other error happened
72+
// }
73+
// }
74+
// }}
75+
// />
76+
// </View>
77+
// );
78+
// }

package-lock.json

Lines changed: 163 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,17 @@
1818
"@expo-google-fonts/poppins": "^0.2.3",
1919
"@expo/vector-icons": "^14.0.2",
2020
"@gorhom/bottom-sheet": "^4.6.4",
21+
"@react-native-async-storage/async-storage": "1.23.1",
2122
"@react-native-community/slider": "4.5.2",
23+
"@react-native-google-signin/google-signin": "^12.2.1",
2224
"@react-navigation/native": "^6.0.2",
25+
"@supabase/supabase-js": "^2.45.1",
2326
"@tanstack/react-query": "^5.51.23",
2427
"axios": "^1.7.4",
2528
"buffer": "^6.0.3",
2629
"color": "^4.2.3",
2730
"expo": "~51.0.28",
31+
"expo-asset": "~10.0.10",
2832
"expo-av": "~14.0.6",
2933
"expo-constants": "~16.0.2",
3034
"expo-crypto": "~13.0.2",
@@ -50,8 +54,8 @@
5054
"react-native-reanimated": "~3.10.1",
5155
"react-native-safe-area-context": "4.10.5",
5256
"react-native-screens": "3.31.1",
53-
"react-native-web": "~0.19.10",
54-
"expo-asset": "~10.0.10"
57+
"react-native-url-polyfill": "^2.0.0",
58+
"react-native-web": "~0.19.10"
5559
},
5660
"devDependencies": {
5761
"@babel/core": "^7.20.0",

0 commit comments

Comments
 (0)