Authentication and Restricting Access to Users

  • kingdragxn-1343765992815464468

    Jay | DRAGXN

    18 days ago

    Hi all, I'm curious about how you all handle authentication and access control (e.g., restricting pages for specific user roles/groups) in Toddle.

    What’s your preferred approach for managing user access? Do you rely on an app provider component, custom actions, or something else?

    If anyone has experience integrating Supabase for this, I'd love to hear your insights!

    Thanks in advance!
  • Tod-1343765993750663219

    Tod

    18 days ago

    Great energy @Jay | DRAGXN! Your continuous contribution to the toddle Community just made you advance to Community Level 1!
  • lucasg-1343769990960119929

    Lucas G

    18 days ago

    You can search up previous discussions on this for details but essentially people often use a wrapper component to handle different contexts, one of which is commonly auth related.

    For Supabase, you can use the auth endpoint to check for the user and handle redirects
  • kingdragxn-1344514211220557824

    Jay | DRAGXN

    16 days ago

    @Lucas G Hey Lucas, I'd like your opinion on this. I have a protectedPage component that's just a combo of my appProvider and authProvider.. the authProvider auto fetchs the user data and I thought I would be able to access that data from the slot. Is that not the case?
    1344514210218119289-image.png
    1344514210628894833-image.png
    1344514211039940701-image.png
  • lucasg-1344520982013939752

    Lucas G

    16 days ago

    What do you mean by access the data from the slot? Are you referring to the context?
  • lucasg-1344521236692078622

    Lucas G

    16 days ago

    You can't subscribe to contexts from a page (since the page is the "highest" element in the hierarchy)
  • kingdragxn-1344521303171792937

    Jay | DRAGXN

    16 days ago

    Yea, I thought I could get the UserData that authProvider gets and anything inside the slot would have access to the data.
  • lucasg-1344521403558400020

    Lucas G

    16 days ago

    You can handle the redirect directly from the authProvider
  • Or have child components subscribe to it to handle different scenarios
  • kingdragxn-1344521559016079401

    Jay | DRAGXN

    16 days ago

    So only components can get the data from authProvider?
  • lucasg-1344521722451333253

    Lucas G

    16 days ago

    Contexts can only be subscribed to by children elements of the provider
  • kingdragxn-1344521893687988255

    Jay | DRAGXN

    16 days ago

    Ah, got you. So for every page that has user data, I have to set up the API everytime?
  • lucasg-1344522207694684200

    Lucas G

    16 days ago

    Pages and components can create contexts but pages cannot subscribe to them (since they can't be children of anything)
  • lucasg-1344522779772325959

    Lucas G

    16 days ago

    I'd use the provider components everywhere and have components use the contexts
  • kingdragxn-1344524535353049109

    Jay | DRAGXN

    16 days ago

    Okay then I'm a bit confused. Would you happen to have an example of something similar to what I'm trying to do? I thought it could be something like this appProvider -> authProvider (Gets User Data) -> Slot -> Anything here can get user data.
  • lucasg-1344534485558890506

    Lucas G

    16 days ago

    That is how it works
  • lucasg-1344535177447342180

    Lucas G

    16 days ago

    Any component in that slot would be a child of the provider
  • Meaning they can subscribe to its context
  • kingdragxn-1344538229004701777

    Jay | DRAGXN

    16 days ago

    Yea I got that part. I'm not sure how to explain it but basically:
    authProvider (Gets User Data) -> Direct children can get the information.
    authProvider (Gets User Data) -> Slot -> Children that aren't components can't get the data. So if I had a H1 and wanted to display the email from User Data, I couldn't.

    Does that make sense?
  • lucasg-1344538997099331658

    Lucas G

    16 days ago

    Yeah that's correct
  • lucasg-1344539116745789441

    Lucas G

    16 days ago

    Sorry, you mentioned it earlier here but I didn't confirm it.

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.