https://supabase.com/ logo
Join DiscordCommunities
Powered by
# javascript
  • r

    rotimi-best

    08/21/2021, 6:33 AM
    For some reason, I can't find documentation on
    supabase.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.
  • f

    florian-lefebvre

    08/21/2021, 7:06 AM
    It expects
    req
    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-auth
  • r

    rotimi-best

    08/21/2021, 7:07 AM
    Okay got it, how about apps using supabase with full client side rendering. No server side code
  • f

    florian-lefebvre

    08/21/2021, 7:07 AM
    Yeah I just noticed
  • f

    florian-lefebvre

    08/21/2021, 7:08 AM
    You can set a custom cookie I think (there is a tutorial on dev.to for Auth with svelte ssr) but you won't be using
    setAuthCookie
  • f

    florian-lefebvre

    08/21/2021, 7:09 AM
    Req and res are only on server side
  • r

    rotimi-best

    08/21/2021, 7:12 AM
    > svelte ssr Did you mean csr?
  • r

    rotimi-best

    08/21/2021, 7:16 AM
    I think some tutorials with CSR would be helpful cause at the end of the day majority deploy to services like netlify or vercel and their free plans support only CSR which therefore makes this API not useful
  • f

    florian-lefebvre

    08/21/2021, 7:40 AM
    I only remember that in this article the author sets a custom cookie for Auth but I don't know if it could also be done on the client side
  • f

    florian-lefebvre

    08/21/2021, 7:42 AM
    Honestly I implemented Auth for the first this week and it was quite hard due to the lack of docs concerning Auth and SSR
  • f

    florian-lefebvre

    08/21/2021, 7:43 AM
    So I think I can't help you more on that topic sorry 😬
  • r

    rotimi-best

    08/21/2021, 7:52 AM
    Thank you. It also took me a while to get a hang of the SSR auth model w/ supabase. Then I decided to deploy to netlify with sapper export. And now I am spending precious development time on figuring out how my whole sapper app can work correctly on prod. Hopeful someone would recommend some tips 🙂
  • e

    Ethanxyz

    08/21/2021, 8:06 AM
    hey everyone i am having issues with Sveltekit + Supabase is some is able to help me. It is a login / signup issue with Magic Link. TLDR: The link is sent and upon clicking, I am redirected back to the site, however, no user is ever added to the database...
  • r

    rotimi-best

    08/21/2021, 8:14 AM
    @User The user is added however not directly to your database table but in a different location.
  • r

    rotimi-best

    08/21/2021, 8:15 AM
    you can also check your localstorage:
    supabase.auth.token
    , that user will be added automatically
  • e

    Ethanxyz

    08/21/2021, 8:20 AM
    Ahh okay I see it now
  • e

    Ethanxyz

    08/21/2021, 8:20 AM
    but thats odd because I have done this in svelte ( not sveltekit ) and it added to a database table
  • e

    Ethanxyz

    08/21/2021, 8:20 AM
    is there a way to add the users to a database table ?
  • e

    Ethanxyz

    08/21/2021, 8:21 AM
    I want to use the user as a FK in another tabel ( for orders ).
  • e

    Ethanxyz

    08/21/2021, 8:21 AM
    Also, I am going off of the svelte starter guide, and so when I use the
    Profile
    page and check for the user with
    auth
    , it won't show and thus the login is pointless right now
  • e

    Ethanxyz

    08/21/2021, 8:21 AM
    I am thinking about just moving to base svelte and using a svelte routers like SPA Router
  • e

    Ethanxyz

    08/21/2021, 8:24 AM
    I am not sure why my other svelte project automatically added users to the table, and this project is not. I followed the same guide with very small changes to help with using sveltekit
  • e

    Ethanxyz

    08/21/2021, 8:30 AM
    Basically, despite being auth in supabase, I always see the login button, despite using the following code...
    Copy code
    jsx
    <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>
  • r

    rotimi-best

    08/21/2021, 8:34 AM
    When you say it automatically added it to the database, what table specifically? Supabase doesn't come with default tables in the db when you create a new project (I could be wrong though). I am aware of the svelte guide you are referring to, it also was not completely helpful for me cause I had issues with creating those policies and auto creating the profile table. At the end of the day what I did was, when I notice a login (using onAuthChange) I just check if that user_id exists in my profile table, if it doesn't I create insert this user into the table and that's all. I am also using sapper, much like sveltekit. Here is my code in my
    __layout.svelte
    Copy code
    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();
        };
      });
  • e

    Ethanxyz

    08/21/2021, 8:35 AM
    Here is the table in my other project. Everytime someone logged in the user was instantly added to this table I didnt even know about that
    authenticated 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 ?
  • e

    Ethanxyz

    08/21/2021, 8:36 AM
    https://supabase.io/docs/guides/with-svelte
  • e

    Ethanxyz

    08/21/2021, 8:36 AM
    Look at this guide. One of the first things it had me do was create a table within the database from a temaplte
  • e

    Ethanxyz

    08/21/2021, 8:36 AM
    which had all sorts of info, including an avatar. This guide even walks you through that.
  • r

    rotimi-best

    08/21/2021, 8:36 AM
    How does it know to add the new user to the `Agents`table? That's what I don't understand
  • r

    rotimi-best

    08/21/2021, 8:37 AM
    I have read this guide over 10 times 😩
1...111213...81Latest