Dashboard per user

Hello,

I have “turned on” the authentication logic with Xano so that future users can authenticate themselves. Now, I want to offer personalised dashboards to my users, using their data. In my database on Xano, I have data for specific users (e.g. Roger =ID 1, Charlotte =ID 2, etc.).

How can I:

  1. Ensure Charlotte, only sees her data (i.e. user rights)
  2. Present Charlotte dashboards only including her data

Thank you very much

For each of your tables in Xano you will want a column that is associated with each user. Then in the API call for data that is populating your dashboard, you will want to use a Precondition to ensure the authenticated user making the call is the user associated with the records.

In my setup, I have company accounts that the users of my app are associated to, so I use a company identifier in my tables, and then the precondition checks that the user making the call is from that company. In my case, I need to use the Xano auth “extras” config to pull the user’s associated company id into the auth settings. If you only care about specific users, your precondition would just use “auth:id” in the conditional statement.

Hope that makes sense.

Hi Eric,

Thank you for your help. I implemented your recommendation and I’d have follow-up questions:

  1. I get a “non-authorised” when I execute the query from Xano, although I selected the right user in the Auth token
  2. I do not have an “admin” role , or variable: how did you set it up?
  3. I can log in on Weweb with the email and password but then when I want to fetch the data from the API I get an error:

Do you know what happens? Thank you again :grinning:

I’ll try my best to steer you in the right direction.

re: 1. Is “user_information_id” the column in your “User_goal_details” table that is a reference to your user table? Make sure capitalization matches too.

re: 2. In my “user” table, I added a Role column, and then setup that field (along with company_id) to get passed in the auth payload. See the documentation here: Authentication - Xano Documentation

I’d remove the second condition until you have that setup.

re: 3. After logging into WeWeb in preview mode, check the Variables to ensure you have an access token set. If so, you should be able to fetch the collection from WeWeb once you get it working in Xano using the debug.

1 Like

Hi Eric,

Many thanks for your time / answer!