diff options
-rw-r--r-- | src/App.tsx | 9 | ||||
-rw-r--r-- | src/pages/Login.tsx | 32 |
2 files changed, 21 insertions, 20 deletions
diff --git a/src/App.tsx b/src/App.tsx index a65251d..47d2c6b 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,10 +1,17 @@ +import { useState } from 'react' + +import { createClient } from '@supabase/supabase-js' + import './App.css' import Login from './pages/Login' +const supabase = createClient('https://slpoocycjgqsuoedhkbn.supabase.co', 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InNscG9vY3ljamdxc3VvZWRoa2JuIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MTUyMDU0MjUsImV4cCI6MjAzMDc4MTQyNX0.xZYRTRN65rlms1Hb96IBAQvw3EGtMzUxlGPP5TVey34') + function App() { + const [session, setSession] = useState(null) return ( <> - <Login /> + <Login supabase={supabase} session={session} setSession={setSession} /> </> ) } diff --git a/src/pages/Login.tsx b/src/pages/Login.tsx index b152b19..d3555cc 100644 --- a/src/pages/Login.tsx +++ b/src/pages/Login.tsx @@ -1,30 +1,24 @@ -import { createClient } from '@supabase/supabase-js' -import { useState, useEffect } from 'react' - -const supabase = createClient('https://slpoocycjgqsuoedhkbn.supabase.co', 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InNscG9vY3ljamdxc3VvZWRoa2JuIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MTUyMDU0MjUsImV4cCI6MjAzMDc4MTQyNX0.xZYRTRN65rlms1Hb96IBAQvw3EGtMzUxlGPP5TVey34') - -window.HandleSignInWithGoogle = async (response: any) => { - console.log(response) - const { data, error } = await supabase.auth.signInWithIdToken({ - provider: 'google', - token: response.credential, - }) - console.log(data, error) -} +import { useEffect } from 'react' -export default function Login() { - const [_, setSession] = useState(null) +export default function Login(props: any) { useEffect(() => { - supabase.auth.getSession().then(({ data: { session } }) => { - setSession(session) + window.HandleSignInWithGoogle = async (response: any) => { + await props.supabase.auth.signInWithIdToken({ + provider: 'google', + token: response.credential, + }) + } + + props.supabase.auth.getSession().then(({ data: { session } }) => { + props.setSession(session) console.log("LOGIN SESSION", session) }) const { data: { subscription }, - } = supabase.auth.onAuthStateChange((_event, session) => { - setSession(session) + } = props.supabase.auth.onAuthStateChange((_event, session) => { + props.setSession(session) console.log("SESSION CHANGE", session) }) |