Redirect user according to variable

I’m on the Weweb starter plan and I don’t have access to the native Roles and Permissions control.

My backend and authenticator is Supabase.

In the collection of my users it has the field ‘tipoUsuario’. When loading the app, I save the logged in user’s document in a variable to consult information when needed.

I want to create a filter so that when the user accesses ‘meusite.com/cadastrar_produto’ and the value of ‘tipoUsuario’ is NOT equal to X, it redirects to another page.

Does anyone know how to do this or can you tell me the most appropriate way, please?

I’m doing it the way below, but even though I run the action before the page loads, it loads the screen first and then redirects it.

Hi, probably you need to make it on app load instead of on page load

If it still blink then your only option is to put a little loader during the check process

1 Like

Has the app lifecycle been documented yet? I remember we spoke about this on the forum multiple times and also in Paris, it’s always an uncertainty for me how to answer when someone asks about what happens when :slight_smile:

I have found it very useful to send uers from Login → App Loading Screen → [landing page].

On the App Loading screen, i place a nice logo and query all of the data needed for that user then navigate to any place in my app based on conditions/ variables :slight_smile: hope this helps, happy to give a Loom if its helpful

2 Likes

The problem is when the user accesses the page link directly

Is it a logged in user? If yes, you can add an attribute in Superbase to Auth so that on load you can know their level