From 88277cfb94694de6226afe4749b8aa3c7a13a58f Mon Sep 17 00:00:00 2001 From: soma Date: Sun, 9 Feb 2025 15:20:29 +0900 Subject: [PATCH 01/11] Add Login component and update Tailwind config --- app/index.tsx | 6 ++++-- fetaure/auth/screen/Login.tsx | 20 ++++++++++++++++++++ tailwind.config.js | 6 +++++- 3 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 fetaure/auth/screen/Login.tsx diff --git a/app/index.tsx b/app/index.tsx index 7b167a34..b87cf8c9 100644 --- a/app/index.tsx +++ b/app/index.tsx @@ -1,10 +1,12 @@ import { Text, View } from "react-native"; +import { Login } from "@/fetaure/auth/screen/Login"; + export default function Index() { return ( - - Hello World, Linpe + Hello World, Linpe + ); } diff --git a/fetaure/auth/screen/Login.tsx b/fetaure/auth/screen/Login.tsx new file mode 100644 index 00000000..381fdbbd --- /dev/null +++ b/fetaure/auth/screen/Login.tsx @@ -0,0 +1,20 @@ +import { Text, TextInput, TouchableOpacity, View } from "react-native"; + +export const Login = () => { + return ( + + Login + + Email + + + + Password + + + + Login + + + ); +}; diff --git a/tailwind.config.js b/tailwind.config.js index 090d7c16..d8e8aca9 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -1,7 +1,11 @@ /** @type {import('tailwindcss').Config} */ module.exports = { // NOTE: Update this to include the paths to all of your component files. - content: ["./app/**/*.{js,jsx,ts,tsx}", "./app/*.{js,jsx,ts,tsx}"], + content: [ + "./app/**/*.{js,jsx,ts,tsx}", + "./app/*.{js,jsx,ts,tsx}", + "./fetaure/**/*.{js,jsx,ts,tsx}", + ], presets: [require("nativewind/preset")], theme: { extend: {}, From c7a938d41684d5e9d50aa86ac2b14ab9c5d0c0a0 Mon Sep 17 00:00:00 2001 From: soma Date: Sun, 9 Feb 2025 15:26:12 +0900 Subject: [PATCH 02/11] Enhance Login component with improved input attributes --- fetaure/auth/screen/Login.tsx | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/fetaure/auth/screen/Login.tsx b/fetaure/auth/screen/Login.tsx index 381fdbbd..b87a1f1f 100644 --- a/fetaure/auth/screen/Login.tsx +++ b/fetaure/auth/screen/Login.tsx @@ -6,11 +6,23 @@ export const Login = () => { Login Email - + Password - + Login From c8fbf6670cc220cfac3d3dae7950af5648620c97 Mon Sep 17 00:00:00 2001 From: soma Date: Sun, 9 Feb 2025 15:39:54 +0900 Subject: [PATCH 03/11] add loginWithEmail function for login --- fetaure/auth/service/authService.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 fetaure/auth/service/authService.ts diff --git a/fetaure/auth/service/authService.ts b/fetaure/auth/service/authService.ts new file mode 100644 index 00000000..8ed0723e --- /dev/null +++ b/fetaure/auth/service/authService.ts @@ -0,0 +1,17 @@ +import supabase from "@/lib/supabase"; + +export const loginWithEmail = async ( + email: string, + password: string, + setLoading: (loading: boolean) => void, +) => { + setLoading(true); + const { error } = await supabase.auth.signInWithPassword({ + email, + password, + }); + setLoading(false); + if (error) { + throw error; + } +}; From c377eed6c371eea0990c32c0c8fd545b60789877 Mon Sep 17 00:00:00 2001 From: soma Date: Sun, 9 Feb 2025 15:47:42 +0900 Subject: [PATCH 04/11] Implement login functionality with state management and Supabase credentials --- fetaure/auth/screen/Login.tsx | 19 ++++++++++++++++++- lib/supabase.ts | 5 +++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/fetaure/auth/screen/Login.tsx b/fetaure/auth/screen/Login.tsx index b87a1f1f..20998fe3 100644 --- a/fetaure/auth/screen/Login.tsx +++ b/fetaure/auth/screen/Login.tsx @@ -1,6 +1,13 @@ +import { useState } from "react"; import { Text, TextInput, TouchableOpacity, View } from "react-native"; +import { loginWithEmail } from "../service/authService"; + export const Login = () => { + const [email, setEmail] = useState(""); + const [password, setPassword] = useState(""); + const [loading, setLoading] = useState(false); + return ( Login @@ -12,6 +19,8 @@ export const Login = () => { textContentType="emailAddress" keyboardType="email-address" autoComplete="email" + value={email} + onChangeText={setEmail} /> @@ -22,9 +31,17 @@ export const Login = () => { textContentType="password" keyboardType="ascii-capable" autoComplete="password" + value={password} + onChangeText={setPassword} /> - + loginWithEmail(email, password, setLoading)} + > Login diff --git a/lib/supabase.ts b/lib/supabase.ts index 86991d68..48eb6e46 100644 --- a/lib/supabase.ts +++ b/lib/supabase.ts @@ -62,8 +62,9 @@ class LargeSecureStore { } } -const supabaseUrl = process.env.SUPABASE_URL; -const supabaseAnonKey = process.env.SUPABASE_ANON_KEY; +const supabaseUrl = "https://lxuurozqrpthyvxvnaml.supabase.co"; +const supabaseAnonKey = + "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Imx4dXVyb3pxcnB0aHl2eHZuYW1sIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MzkwNzg0NjYsImV4cCI6MjA1NDY1NDQ2Nn0.m8YcHx4RNlRRi4-GsnQTg5h_X_WfRlSY7iYKVmhZCTU"; const supabase = createClient(supabaseUrl || "", supabaseAnonKey || "", { auth: { From a39fd948072f3b8ab33c9e9089d855c2340c70d7 Mon Sep 17 00:00:00 2001 From: soma Date: Sun, 9 Feb 2025 15:55:27 +0900 Subject: [PATCH 05/11] zRefactor Login component and error handling with new UI components --- .env.dev | 3 --- .env.example | 3 --- components/button/PrimaryButton.tsx | 23 +++++++++++++++++++++++ components/link/DefaultLink.tsx | 15 +++++++++++++++ fetaure/auth/screen/Login.tsx | 16 +++++++++------- fetaure/auth/service/authService.ts | 8 +++++--- 6 files changed, 52 insertions(+), 16 deletions(-) delete mode 100644 .env.dev delete mode 100644 .env.example create mode 100644 components/button/PrimaryButton.tsx create mode 100644 components/link/DefaultLink.tsx diff --git a/.env.dev b/.env.dev deleted file mode 100644 index e79a19c0..00000000 --- a/.env.dev +++ /dev/null @@ -1,3 +0,0 @@ -SUPABASE_DB_PASSWORD="AYH3i8hOkqZSY4Yx" -SUPABASE_ANNON_KEY="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Imx4dXVyb3pxcnB0aHl2eHZuYW1sIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MzkwNzg0NjYsImV4cCI6MjA1NDY1NDQ2Nn0.m8YcHx4RNlRRi4-GsnQTg5h_X_WfRlSY7iYKVmhZCTU" -SUPABASE_URL="https://lxuurozqrpthyvxvnaml.supabase.co" \ No newline at end of file diff --git a/.env.example b/.env.example deleted file mode 100644 index ce3c1262..00000000 --- a/.env.example +++ /dev/null @@ -1,3 +0,0 @@ -SUPABASE_DB_PASSWORD= -SUPABASE_ANNON_KEY= -SUPABASE_URL= \ No newline at end of file diff --git a/components/button/PrimaryButton.tsx b/components/button/PrimaryButton.tsx new file mode 100644 index 00000000..43dede7d --- /dev/null +++ b/components/button/PrimaryButton.tsx @@ -0,0 +1,23 @@ +import { TouchableOpacity } from "react-native"; + +export const PrimaryButton = ({ + children, + onPress, + loading = false, +}: { + children: React.ReactNode; + onPress: () => void; + loading?: boolean; +}) => { + return ( + + {children} + + ); +}; diff --git a/components/link/DefaultLink.tsx b/components/link/DefaultLink.tsx new file mode 100644 index 00000000..e3f049e5 --- /dev/null +++ b/components/link/DefaultLink.tsx @@ -0,0 +1,15 @@ +import { TouchableOpacity } from "react-native"; + +export const DefaultLink = ({ + children, + onPress, +}: { + children: React.ReactNode; + onPress: () => void; +}) => { + return ( + + {children} + + ); +}; diff --git a/fetaure/auth/screen/Login.tsx b/fetaure/auth/screen/Login.tsx index 20998fe3..b4182e88 100644 --- a/fetaure/auth/screen/Login.tsx +++ b/fetaure/auth/screen/Login.tsx @@ -1,6 +1,8 @@ import { useState } from "react"; -import { Text, TextInput, TouchableOpacity, View } from "react-native"; +import { Text, TextInput, View } from "react-native"; +import { PrimaryButton } from "@/components/button/PrimaryButton"; +import { DefaultLink } from "@/components/link/DefaultLink"; import { loginWithEmail } from "../service/authService"; export const Login = () => { @@ -35,15 +37,15 @@ export const Login = () => { onChangeText={setPassword} /> - loginWithEmail(email, password, setLoading)} + loading={loading} > Login - + + {}}> + Signup + ); }; diff --git a/fetaure/auth/service/authService.ts b/fetaure/auth/service/authService.ts index 8ed0723e..0bc0e2ff 100644 --- a/fetaure/auth/service/authService.ts +++ b/fetaure/auth/service/authService.ts @@ -1,3 +1,5 @@ +import { Alert } from "react-native"; + import supabase from "@/lib/supabase"; export const loginWithEmail = async ( @@ -10,8 +12,8 @@ export const loginWithEmail = async ( email, password, }); + + if (error) Alert.alert(error.message); + setLoading(false); - if (error) { - throw error; - } }; From 64fc2f14dd73f8e585f7cbfd48ecfe8cbab09fbd Mon Sep 17 00:00:00 2001 From: soma Date: Sun, 9 Feb 2025 15:58:51 +0900 Subject: [PATCH 06/11] Add Signup component to main index screen --- app/index.tsx | 2 ++ fetaure/auth/screen/Signup.tsx | 38 ++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 fetaure/auth/screen/Signup.tsx diff --git a/app/index.tsx b/app/index.tsx index b87cf8c9..206901a8 100644 --- a/app/index.tsx +++ b/app/index.tsx @@ -1,12 +1,14 @@ import { Text, View } from "react-native"; import { Login } from "@/fetaure/auth/screen/Login"; +import { Signup } from "@/fetaure/auth/screen/Signup"; export default function Index() { return ( Hello World, Linpe + ); } diff --git a/fetaure/auth/screen/Signup.tsx b/fetaure/auth/screen/Signup.tsx new file mode 100644 index 00000000..e7c0a1ff --- /dev/null +++ b/fetaure/auth/screen/Signup.tsx @@ -0,0 +1,38 @@ +import { Text, TextInput, View } from "react-native"; + +import { PrimaryButton } from "@/components/button/PrimaryButton"; +import { DefaultLink } from "@/components/link/DefaultLink"; + +export const Signup = () => { + return ( + + Signup + + Email + + + + Password + + + {}}> + Signup + + {}}> + Login + + + ); +}; From 88157a00a1ab5d31184f8d2ad388b0485f982e97 Mon Sep 17 00:00:00 2001 From: soma Date: Sun, 9 Feb 2025 16:01:57 +0900 Subject: [PATCH 07/11] Implement signup functionality with email and password --- fetaure/auth/screen/Signup.tsx | 15 ++++++++++++++- fetaure/auth/service/authService.ts | 18 ++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/fetaure/auth/screen/Signup.tsx b/fetaure/auth/screen/Signup.tsx index e7c0a1ff..940a833a 100644 --- a/fetaure/auth/screen/Signup.tsx +++ b/fetaure/auth/screen/Signup.tsx @@ -1,9 +1,15 @@ +import { useState } from "react"; import { Text, TextInput, View } from "react-native"; import { PrimaryButton } from "@/components/button/PrimaryButton"; import { DefaultLink } from "@/components/link/DefaultLink"; +import { signupWithEmail } from "../service/authService"; export const Signup = () => { + const [email, setEmail] = useState(""); + const [password, setPassword] = useState(""); + const [loading, setLoading] = useState(false); + return ( Signup @@ -15,6 +21,8 @@ export const Signup = () => { textContentType="emailAddress" keyboardType="email-address" autoComplete="email" + value={email} + onChangeText={setEmail} /> @@ -25,9 +33,14 @@ export const Signup = () => { textContentType="password" keyboardType="ascii-capable" autoComplete="password" + value={password} + onChangeText={setPassword} /> - {}}> + signupWithEmail(email, password, setLoading)} + loading={loading} + > Signup {}}> diff --git a/fetaure/auth/service/authService.ts b/fetaure/auth/service/authService.ts index 0bc0e2ff..f64c3661 100644 --- a/fetaure/auth/service/authService.ts +++ b/fetaure/auth/service/authService.ts @@ -17,3 +17,21 @@ export const loginWithEmail = async ( setLoading(false); }; + +export const signupWithEmail = async ( + email: string, + password: string, + setLoading: (loading: boolean) => void, +) => { + setLoading(true); + const { + data: { session }, + error, + } = await supabase.auth.signUp({ + email, + password, + }); + if (error) Alert.alert(error.message); + if (!session) Alert.alert("Please check your inbox for email verification!"); + setLoading(false); +}; From 1c55f741746bcb5cc3b5fa313eda30dffa8caf71 Mon Sep 17 00:00:00 2001 From: soma Date: Sun, 9 Feb 2025 16:22:02 +0900 Subject: [PATCH 08/11] Refactor root layout to manage authentication state with Supabase --- app/(auth)/_layout.tsx | 10 ++++++ app/(auth)/loginScreen.tsx | 11 +++++++ app/(auth)/signupScreen.tsx | 11 +++++++ app/(protected)/_layout.tsx | 54 +++++++++++++++++++++++++++++++++ app/{ => (protected)}/index.tsx | 5 --- app/_layout.tsx | 28 +++++++++++++++-- 6 files changed, 112 insertions(+), 7 deletions(-) create mode 100644 app/(auth)/_layout.tsx create mode 100644 app/(auth)/loginScreen.tsx create mode 100644 app/(auth)/signupScreen.tsx create mode 100644 app/(protected)/_layout.tsx rename app/{ => (protected)}/index.tsx (62%) diff --git a/app/(auth)/_layout.tsx b/app/(auth)/_layout.tsx new file mode 100644 index 00000000..b8c5721b --- /dev/null +++ b/app/(auth)/_layout.tsx @@ -0,0 +1,10 @@ +import { SafeAreaView } from "react-native"; +import { Slot } from "expo-router"; + +export default function AuthLayout() { + return ( + + + + ); +} diff --git a/app/(auth)/loginScreen.tsx b/app/(auth)/loginScreen.tsx new file mode 100644 index 00000000..a5c7fdb9 --- /dev/null +++ b/app/(auth)/loginScreen.tsx @@ -0,0 +1,11 @@ +import { View } from "react-native"; + +import { Login } from "@/fetaure/auth/screen/Login"; + +export default function LoginScreen() { + return ( + + + + ); +} diff --git a/app/(auth)/signupScreen.tsx b/app/(auth)/signupScreen.tsx new file mode 100644 index 00000000..185dfef9 --- /dev/null +++ b/app/(auth)/signupScreen.tsx @@ -0,0 +1,11 @@ +import { View } from "react-native"; + +import { Signup } from "@/fetaure/auth/screen/Signup"; + +export default function SignupScreen() { + return ( + + + + ); +} diff --git a/app/(protected)/_layout.tsx b/app/(protected)/_layout.tsx new file mode 100644 index 00000000..53411a7c --- /dev/null +++ b/app/(protected)/_layout.tsx @@ -0,0 +1,54 @@ +// app/(protected)/_layout.tsx +import { useEffect, useState } from "react"; +import { ActivityIndicator, View } from "react-native"; +import { Slot, useRouter } from "expo-router"; +import { type User } from "@supabase/supabase-js"; + +import supabase from "@/lib/supabase"; + +export default function ProtectedLayout() { + const router = useRouter(); + const [user, setUser] = useState(null); + const [loading, setLoading] = useState(true); + + useEffect(() => { + // 現在のセッションを取得 + const getSession = async () => { + const { + data: { session }, + } = await supabase.auth.getSession(); + setUser(session?.user ?? null); + setLoading(false); + }; + getSession(); + + // 認証状態の変化を監視 + const { + data: { subscription }, + } = supabase.auth.onAuthStateChange((_event, session) => { + setUser(session?.user ?? null); + }); + return () => subscription?.unsubscribe(); + }, []); + + useEffect(() => { + if (!loading && !user) { + router.replace("/loginScreen"); + } + }, [user, loading, router]); + + if (loading) { + // ローディング中はインジケーターを表示 + return ( + + + + ); + } + + if (!user) { + return null; + } + + return ; +} diff --git a/app/index.tsx b/app/(protected)/index.tsx similarity index 62% rename from app/index.tsx rename to app/(protected)/index.tsx index 206901a8..4162d2a5 100644 --- a/app/index.tsx +++ b/app/(protected)/index.tsx @@ -1,14 +1,9 @@ import { Text, View } from "react-native"; -import { Login } from "@/fetaure/auth/screen/Login"; -import { Signup } from "@/fetaure/auth/screen/Signup"; - export default function Index() { return ( Hello World, Linpe - - ); } diff --git a/app/_layout.tsx b/app/_layout.tsx index 3112b2bf..2f6d667d 100644 --- a/app/_layout.tsx +++ b/app/_layout.tsx @@ -1,7 +1,31 @@ -import { Stack } from "expo-router"; +// app/_layout.jsx +import { SafeAreaView, Text } from "react-native"; +import { Slot } from "expo-router"; import "../assets/styles/global.css"; +import { useEffect, useState } from "react"; +import { type Session } from "@supabase/supabase-js"; + +import supabase from "@/lib/supabase"; + export default function RootLayout() { - return ; + const [session, setSession] = useState(null); + + useEffect(() => { + supabase.auth.getSession().then(({ data: { session } }) => { + setSession(session); + }); + + supabase.auth.onAuthStateChange((_event, session) => { + setSession(session); + }); + }, []); + + return ( + + {session ? "ログイン済み" : "未ログイン"} + + + ); } From a189acc188a2b489bcb6f497236df9ec8caea0e5 Mon Sep 17 00:00:00 2001 From: soma Date: Sun, 9 Feb 2025 16:25:32 +0900 Subject: [PATCH 09/11] Refactor DefaultLink to use Expo Router Link for navigation --- components/link/DefaultLink.tsx | 19 +++++++++---------- fetaure/auth/screen/Login.tsx | 2 +- fetaure/auth/screen/Signup.tsx | 2 +- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/components/link/DefaultLink.tsx b/components/link/DefaultLink.tsx index e3f049e5..cdf9ba0c 100644 --- a/components/link/DefaultLink.tsx +++ b/components/link/DefaultLink.tsx @@ -1,15 +1,14 @@ -import { TouchableOpacity } from "react-native"; +import { Link } from "expo-router"; -export const DefaultLink = ({ - children, - onPress, -}: { - children: React.ReactNode; - onPress: () => void; -}) => { +type DefaultLinkProps = Pick< + React.ComponentProps, + "children" | "href" +>; + +export const DefaultLink = ({ children, href }: DefaultLinkProps) => { return ( - + {children} - + ); }; diff --git a/fetaure/auth/screen/Login.tsx b/fetaure/auth/screen/Login.tsx index b4182e88..1c2b9b3d 100644 --- a/fetaure/auth/screen/Login.tsx +++ b/fetaure/auth/screen/Login.tsx @@ -43,7 +43,7 @@ export const Login = () => { > Login - {}}> + Signup diff --git a/fetaure/auth/screen/Signup.tsx b/fetaure/auth/screen/Signup.tsx index 940a833a..a4010c77 100644 --- a/fetaure/auth/screen/Signup.tsx +++ b/fetaure/auth/screen/Signup.tsx @@ -43,7 +43,7 @@ export const Signup = () => { > Signup - {}}> + Login From 1ba83574f9636800045350339f32efecbf7d08b2 Mon Sep 17 00:00:00 2001 From: soma Date: Sun, 9 Feb 2025 16:31:46 +0900 Subject: [PATCH 10/11] Implement authentication routing and add signout button to protected route --- app/(protected)/index.tsx | 3 +++ app/_layout.tsx | 17 ++++++++++++++++- fetaure/auth/components/SignoutButton.tsx | 11 +++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 fetaure/auth/components/SignoutButton.tsx diff --git a/app/(protected)/index.tsx b/app/(protected)/index.tsx index 4162d2a5..7b932301 100644 --- a/app/(protected)/index.tsx +++ b/app/(protected)/index.tsx @@ -1,9 +1,12 @@ import { Text, View } from "react-native"; +import { SignoutButton } from "@/fetaure/auth/components/SignoutButton"; + export default function Index() { return ( Hello World, Linpe + ); } diff --git a/app/_layout.tsx b/app/_layout.tsx index 2f6d667d..e0eb027a 100644 --- a/app/_layout.tsx +++ b/app/_layout.tsx @@ -1,6 +1,6 @@ // app/_layout.jsx import { SafeAreaView, Text } from "react-native"; -import { Slot } from "expo-router"; +import { Slot, useRouter, useSegments } from "expo-router"; import "../assets/styles/global.css"; @@ -11,6 +11,8 @@ import supabase from "@/lib/supabase"; export default function RootLayout() { const [session, setSession] = useState(null); + const segments = useSegments(); + const router = useRouter(); useEffect(() => { supabase.auth.getSession().then(({ data: { session } }) => { @@ -22,6 +24,19 @@ export default function RootLayout() { }); }, []); + useEffect(() => { + const inAuthGroup = segments[0] === "(auth)"; + const inProtectedGroup = segments[0] === "(protected)"; + + if (session && inAuthGroup) { + // ログイン済みで認証画面にいる場合は、protectedにリダイレクト + router.replace("/(protected)"); + } else if (!session && inProtectedGroup) { + // 未ログインでprotected画面にいる場合は、認証画面にリダイレクト + router.replace("/(auth)/loginScreen"); + } + }, [session, segments, router]); + return ( {session ? "ログイン済み" : "未ログイン"} diff --git a/fetaure/auth/components/SignoutButton.tsx b/fetaure/auth/components/SignoutButton.tsx new file mode 100644 index 00000000..e3d6b87c --- /dev/null +++ b/fetaure/auth/components/SignoutButton.tsx @@ -0,0 +1,11 @@ +import { Text } from "react-native"; + +import { PrimaryButton } from "@/components/button/PrimaryButton"; + +export const SignoutButton = () => { + return ( + {}}> + Signout + + ); +}; From 707a2982d86eb515abd6e0d53f70ba43fe4547dc Mon Sep 17 00:00:00 2001 From: soma Date: Sun, 9 Feb 2025 16:33:17 +0900 Subject: [PATCH 11/11] Implement signout functionality in authentication service --- fetaure/auth/components/SignoutButton.tsx | 3 ++- fetaure/auth/service/authService.ts | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/fetaure/auth/components/SignoutButton.tsx b/fetaure/auth/components/SignoutButton.tsx index e3d6b87c..1baf538a 100644 --- a/fetaure/auth/components/SignoutButton.tsx +++ b/fetaure/auth/components/SignoutButton.tsx @@ -1,10 +1,11 @@ import { Text } from "react-native"; import { PrimaryButton } from "@/components/button/PrimaryButton"; +import { signout } from "../service/authService"; export const SignoutButton = () => { return ( - {}}> + signout()}> Signout ); diff --git a/fetaure/auth/service/authService.ts b/fetaure/auth/service/authService.ts index f64c3661..14a76f8d 100644 --- a/fetaure/auth/service/authService.ts +++ b/fetaure/auth/service/authService.ts @@ -35,3 +35,8 @@ export const signupWithEmail = async ( if (!session) Alert.alert("Please check your inbox for email verification!"); setLoading(false); }; + +export const signout = async () => { + const { error } = await supabase.auth.signOut(); + if (error) Alert.alert(error.message); +};