'On page load (before fetching collections) is not working in production mode

Some pages in my application have a conditional action when the page loads. “If the user has the email field = ‘xyz’” it directs the user to another screen (access blocked).

Behavior in dev mode:
When accessing the page without having ‘permission’, either through a button or by adding the link in the search bar, the user is quickly redirected to the page defined in the workflow, the screen turns completely white for about 2 seconds and the content is loaded.

Behavior in production mode:
When accessing the page without having ‘permission’, either through a button or by adding the link in the search bar, the screen elements are loaded (a form, for example) and after about 5 seconds, the user is redirected to the previous screen.

I can’t take the risk of showing an admin screen to any user.

If anyone on the WW team wants, I have a video of how it works. I can’t post here to avoid exposing the project.

I don’t think this is a very safe method maybe take a look into the user roles section of your backend for example heres the supabase one

you can then restrict access to a page based on there roll.

1 Like

I’m using the Starter plan, unfortunately I don’t have access to the Roles and Permissions feature. It would be amazing! thanks

Back here after a while. Feels good :blush:.

Now straight to helping out on this

Here’s how to gate that page properly and have no risk of showing it to a user without permission.

  1. Have a boolean field in your database that will decide whether the user is permitted or not (so Is_admin (true or false)

  2. When you’re done creating all of the UI go to the settings tab of EACH section on the page and set a conditional visibility (USE THE SETTINGS TAB, very important). Use a boolean variable. E.g show_data (true or false), set the default for that variable to be false.

  3. Now on page load check if the is_admin data field of current user is true, if true, change variable value show_data to true. If false, navigate to correct page.

Voila! Your page will load blank for any user who is not admin, NO MATTER HOW LONG it takes to load they will see nothing, even if they inspect the source code they will see nothing.

2 Likes

Seconding @AgentD, starting with false by default improves UX big time.

2 Likes

Man, I thought of this yesterday and worked pleasantly! I was just hoping for some other useful information on the subject and was very excited that the alternative worked well. Thank you guys!

Unless you want to pay for the higher tier (where I think they do the redirect even before the page loads?) this is your best bet :slight_smile:

1 Like