rotimi-best
08/21/2021, 6:33 AMsupabase.auth.api.setAuthCookieflorian-lefebvre
08/21/2021, 7:06 AMreqresrotimi-best
08/21/2021, 7:07 AMflorian-lefebvre
08/21/2021, 7:07 AMflorian-lefebvre
08/21/2021, 7:08 AMsetAuthCookieflorian-lefebvre
08/21/2021, 7:09 AMrotimi-best
08/21/2021, 7:12 AMrotimi-best
08/21/2021, 7:16 AMflorian-lefebvre
08/21/2021, 7:40 AMflorian-lefebvre
08/21/2021, 7:42 AMflorian-lefebvre
08/21/2021, 7:43 AMrotimi-best
08/21/2021, 7:52 AMEthanxyz
08/21/2021, 8:06 AMrotimi-best
08/21/2021, 8:14 AMrotimi-best
08/21/2021, 8:15 AMsupabase.auth.tokenEthanxyz
08/21/2021, 8:20 AMEthanxyz
08/21/2021, 8:20 AMEthanxyz
08/21/2021, 8:20 AMEthanxyz
08/21/2021, 8:21 AMEthanxyz
08/21/2021, 8:21 AMProfileauthEthanxyz
08/21/2021, 8:21 AMEthanxyz
08/21/2021, 8:24 AMEthanxyz
08/21/2021, 8:30 AMjsx
<script>
 // supabase imports
  import { user } from "../sessionStore";
  import { supabase } from "../supabaseClient";
  import Auth from "../Auth.svelte";
//   import Profile from "../routes/Profile.svelte"
  user.set(supabase.auth.user());
  supabase.auth.onAuthStateChange((_, session) => {
    user.set(session.user);
  });
</script>
<main>
{#if $user}
        <h1>User Logged In</h1>
    {:else}
        <Auth />
    {/if}
</main>rotimi-best
08/21/2021, 8:34 AM__layout.sveltejs
onMount(() => {
    const { data: authListener } = supabase.auth.onAuthStateChange(
      (event, session) => {
        // Cause my dev environment is server side rendered but my prod on netlify uses `sapper export` so I can't set the cookies
        if (config.isDev) {
          handleAuthChange(event, session);
        }
        if (event === 'SIGNED_IN') {
          $user.fetchingUser = true;
          getProfile(); // This function creates a new profile if doesn't 
        } else {
          console.log('not logged in, go to login');
          return goto('/login');
        }
      }
    );
    return () => {
      authListener.unsubscribe();
    };
  });Ethanxyz
08/21/2021, 8:35 AMauthenticated usersEthanxyz
08/21/2021, 8:36 AMEthanxyz
08/21/2021, 8:36 AMEthanxyz
08/21/2021, 8:36 AMrotimi-best
08/21/2021, 8:36 AMrotimi-best
08/21/2021, 8:37 AM