rotimi-best
08/21/2021, 6:33 AMsupabase.auth.api.setAuthCookie
, I couldn't even find `setAuthCookie`in the docs. However I see it used in tutorials. Does anyone have any explanation to the actual arguments this function expects and their types?
My main need is to understand how to set the cookie when using client side rendering, rather than server side.florian-lefebvre
08/21/2021, 7:06 AMreq
and res
like an express route. There is a great example to understand it: https://github.com/supabase/supabase/tree/master/examples%2Fnextjs-with-supabase-authrotimi-best
08/21/2021, 7:07 AMflorian-lefebvre
08/21/2021, 7:07 AMflorian-lefebvre
08/21/2021, 7:08 AMsetAuthCookie
florian-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.token
, that user will be added automaticallyEthanxyz
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 AMProfile
page and check for the user with auth
, it won't show and thus the login is pointless right nowEthanxyz
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.svelte
js
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 users
section of supabase... I just assumed the users lived in the table. This is the first I am hearing of it...
Is this sveltekit specific or something ?Ethanxyz
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