https://supabase.com/ logo
Join Discord
Powered by
# help
  • m

    Maz

    01/09/2022, 10:57 PM
    Is it possible to sort the results of a foreign key sub-array? Say I have a query like this:
    Copy code
    await supabase
    .from('Things')
    .select('*, other:OtherThings(*)')
    .order('created_at')
    I want to sort the main results by
    created_at
    which is on
    Things
    , but then I want to sort the sub-array
    other
    by something else
  • d

    danny.m

    01/09/2022, 11:00 PM
    Has anybody else encountered this error when attempting to use 3rd party auth?
    Error getting user email from external provider
  • d

    danny.m

    01/09/2022, 11:00 PM
    I'm trying use github
  • g

    Grymer

    01/09/2022, 11:13 PM
    Can I do RLS that only allow commands if certain property is true for that row
  • g

    Grymer

    01/09/2022, 11:13 PM
    I am making a product-page and want to be able to hide products. So public is only allowed to access if
    product.public === true
  • j

    jensen

    01/09/2022, 11:36 PM
    Yes this would be one of the checks in your policy.
  • g

    Grymer

    01/09/2022, 11:37 PM
    How exactly do I write this out. Sorry for such noobish question, but where ever I look for a question seems quite a tad from Supabase which gets me confused :/
  • j

    jensen

    01/09/2022, 11:38 PM
    Ok, are you using the Dashboard UI to add your RLS policies?
  • g

    Grymer

    01/09/2022, 11:39 PM
    Yeah! I'm trying this right now
  • g

    Grymer

    01/09/2022, 11:39 PM
    However I have not setup the functionality to test it yet. Would this be doable?
  • j

    jensen

    01/09/2022, 11:40 PM
    Yes. I have done just this a few weeks ago. I'll confirm my project in the UI.
  • j

    jensen

    01/09/2022, 11:41 PM
    So if you purely want to lock it down for everyone unless it is public, the that shoudl do it for you.
  • g

    Grymer

    01/09/2022, 11:41 PM
    Thanks a lot!! Do you happen to know anything about SvelteKit?
  • j

    jensen

    01/09/2022, 11:42 PM
    Then you can add more cases to that policy if you want to make non public resources available to their owner, or admins.
  • j

    jensen

    01/09/2022, 11:42 PM
    I spend most of my time with React. But if you can't figure out your issue I might still be able to help.
  • g

    Grymer

    01/09/2022, 11:43 PM
    SvelteKit has SSR, and this product page use the server-side-rendering to speed things up. I am however unsure as to how I should properly pass the Supabase state to the webpage
  • j

    jensen

    01/09/2022, 11:43 PM
    oh
  • j

    jensen

    01/09/2022, 11:43 PM
    ok well that is a general problem
  • j

    jensen

    01/09/2022, 11:43 PM
    I've been doing SSR with remix lately
  • j

    jensen

    01/09/2022, 11:43 PM
    It works on the server pretty well, except auth is a bit of a pain, since auth is client focused
  • g

    Grymer

    01/09/2022, 11:44 PM
    To my understanding the session of supabase is saved in Localstorage right?
  • j

    jensen

    01/09/2022, 11:45 PM
    Yeah, that is the normal path
  • g

    Grymer

    01/09/2022, 11:46 PM
    So before the page has loaded (First page hit), the session has not loaded up, and there is no way to pass the session of the user to the server. Is this right? Or is there a way to ship the session of the user?
  • j

    jensen

    01/09/2022, 11:46 PM
    With email signups it looks like you can do stuff with the API, but with providers it seems client side only
  • j

    jensen

    01/09/2022, 11:46 PM
    well you would duplicate the token
  • j

    jensen

    01/09/2022, 11:46 PM
    and provide it to the server, which can store it as a cookie
  • j

    jensen

    01/09/2022, 11:48 PM
    there is a callback for the client I use:
    Copy code
    supabase.auth.onAuthStateChange(
      (event, session) => {
        const body = { event, token: session?.access_token ?? "" };
          submit(body, { method: "post" });
      }
    );
  • j

    jensen

    01/09/2022, 11:49 PM
    So when I am returned to the client, I can make that call to the back end, and that results in a cookie being created, that is sent with every further request.
  • j

    jensen

    01/09/2022, 11:50 PM
    Copy code
    export let action: ActionFunction = ({ request }) => {
      return Promise.all([
        cookie.getSession(request.headers.get("Cookie")),
        request.formData(),
      ]).then(([session, body]) => {
        const event = body.get("event");
        const token = body.get("token");
    
        if (event === "SIGNED_IN") {
          session.set("token", token);
    
          return cookie.commitSession(session).then((cookie) => {
            return redirect("/", {
              headers: {
                "Set-Cookie": cookie,
              },
            });
          });
        }
    
        return cookie.destroySession(session).then((cookie) =>
          redirect("/", {
            headers: {
              "Set-Cookie": cookie,
            },
          })
        );
      });
    };
    This is how I create the cookie in remix (on the server)
  • j

    jensen

    01/09/2022, 11:51 PM
    None of this is production ready by the way, I've been messing around the last couple weeks.
1...189190191...316Latest