Redirect base on identity value

On my login page I am checking if the identity exists, if it does re-direct to the app dashboard page.

If identity is more than or equal to 1 redirect if not say on the login page.

I tried doing it via code as well:
if (sc_is_user_logged_in.data.identity >= 1) {'app/dashboard'}

You need the Browser component added to the page (default name browser1) then use that to enable the redirects

Then try

sc_is_user_logged_in.data.identity >= 1 ? browser1.goto(‘app/dashboard’) : browser1.goto(‘login’)

You may need to change the routes to match what you need

1 Like

I’ve tired that already, ended up in a endless loop because the login page is where the identity is being checked.

I am wondering if there is a way to cancel the action if the identity is 0 or blank.

For example:
sc_is_user_logged_in.data.identity >= 1 ? browser1.goto(‘app/dashboard’) : cancel

Sounds to me like you must have the logic wrong

On your login page you call the login server action via the server connect form and then place the redirect on the dynamic success event of the server connect form./
That way the redirect happens if the server returns success from the login api otherwise the user remains on the login page
There should be no need to check the Identity
I suggest you watch this video
https://studio.youtube.com/video/3Xrg4EUMRIQ/edit

That’s exactly how my login page is working.

What I am trying to accomplish is if the user ever visit back login page and he or she were login maybe hours ago or days until it’s expired I don’t want them to enter their credentials again to reach the backend app. I want the page to dynamically check and forward them to the backend app.

Steps I am trying to accomplish:

  1. Check identity exists
  2. Redirect (browser front end)
    If identity doesn’t exists stay on the login page.

Okay here is my solutions, after taking a break; I am only few days new to Wappler, so maybe it’s not the best of solution.

Page flow: