PricingDocsAcademy
Bluesky ...
Fri, Dec 13, 8:14 AM

How are you gating pages?

  • Chris Laupama

    3 months ago

    Let's say I have a login, signup and home page.

    I want the home page to be gated ( require a logged in user to see it )

    Are you creating an "On load" lifecycle event? ( if so, how are you doing this? I keep getting stuck on a switch statement )

    Or are you making an API call and having the success do nothing, or maybe just store something and have the error flow use the "Go to URL" action?

    Thinking of the best way to do it, but interestingly I just can't get my head around getting the "On load" even working as I'm checking the session cookie and that doesn't seem to be working...
  • I have Supabase auth setup and working correctly for reference with the access_token being stored in the session cookies.
  • Chris Laupama

    3 months ago

    ATM - the route I think I'm going to take is just to make an API auto-fetch call to the supabase "GET USER" endpoint.

    If successful do nothing.
    If error - trigger the "GO TO URL" action.

    ---

    I'm just thinking that since I have the session cookie stored, surely I can use that... just check for that in the "On load" lifecycle event.
  • Max

    3 months ago

    Hi Chris! You cannot check the session cookie on load. On load happens in the browser and this is an http cookie, so you won't be able to access it
  • Chris Laupama

    3 months ago

    Ah so the fetch route would be the way to go yeah?
  • Max

    3 months ago

    That is one option. Another one is to use the new get cookie in a formula that evaluates server side. Could work, but I haven't tried it yet
  • Erik Beuschau

    3 months ago

    With the new APIs we're rolling out (soon), you will be able to setup server-side redirect rules based on an API's response, it's statuscode or a cookie provided by the client.
    πŸ‘€2
    πŸ™ŒπŸ½2

Stop scrolling. Start building.

toddle is a visual web app builder that rivals custom code β€” but accessible to your entire team!

Try toddle β€” it's free!

Β© Copyright 2024 toddle. All rights reserved.