Get value of logged in user from supabase

Actions & Logic

Hello mates!

I have an app which using supabase and i would like after sign in to get the company id of the logged in user and store it to app state variable. I have already created the relation of my "users" table with "auth.users" table of supabase.

What have you tried so far?
  1. Capture Company ID on Login:

    • After a successful login (using Supabase Authentication action), create an action to fetch the user's details.

    • Within this action:

      • Use a Supabase "Select from Table" action to retrieve user data from your Supabase table (e.g., "users").

      • Filter the query based on the logged-in user's ID (accessible from the "Supabase User" variable).

      • In the "Action Output Variables," define a variable named company_id to store the retrieved company ID from the user data.

  2. Store Company ID in App State:

    • Add a new App State variable named company_id (type: String).

    • In the same action from step 1, use a "Set App State" action to set the value of the company_id App State variable to the company_id action output variable.

  3. Access Company ID Anywhere:

    • You can now access the company ID of the logged-in user from any screen or action using the company_id App State variable.

Did you check FlutterFlow's Documentation for this topic?
No
1 reply