about summary refs log tree commit diff
path: root/src/pages/Login.tsx
blob: d3555cc67258ce8e265b58e22e54726f5712e04d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import { useEffect } from 'react'

export default function Login(props: any) {

  useEffect(() => {
    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 },
    } = props.supabase.auth.onAuthStateChange((_event, session) => {
      props.setSession(session)
      console.log("SESSION CHANGE", session)
    })

    return () => subscription.unsubscribe()
  }, [])

  return (
    <>
      <div>
        <h1>Login</h1>
        <p>Log in to access your account!</p>
      </div>

      <div id="g_id_onload"
        data-client_id="952965459060-nrnrsdoq22mf646vfa72hk410pvdda5q.apps.googleusercontent.com"
        data-context="signin"
        data-ux_mode="popup"
        data-callback="HandleSignInWithGoogle"
        data-auto_prompt="false">
      </div>

      <div className="g_id_signin"
        data-type="standard"
        data-shape="pill"
        data-theme="outline"
        data-text="signin"
        data-size="large"
        data-logo_alignment="center">
      </div>
    </>
  )
}