Redirect to login page action on every page if current user not logged in - not working but maybe something trivial

I want to have the user redirected to the login page if they are are another page and are not logged in.

Based on Requiring login? (SOLVED) - #4 by ethan, I created a reusable header that has a General workflow whose When condition is if the Current User Is not Logged In, and then it should navigate to the login page.

I put it in a reusable element so that I can just put it in every page and was hoping it would just work.

Now, the workflow seems to get triggered, and in stepping through the workflow I see it act like it is about execute the Navigate action, but it doesn’t actually navigate anywhere.

Is this something that wouldn’t work in preview/debug mode?

Note - I added the folder to the action just to see what it did - it wasn’t working without it either.

Thanks!

Why wouldn’t you have an “on page load” instead of a “do everytime?”

Also, make sure this functionality is not set to run on the login page itself, or you might run into a constant refresh battle once you get to the login page.

2 Likes

I’m using the “on page load” as well. It works perfectly for me.

thx - I changed it to the page_load and navigate when the current user hnot logged in (for some reason have to add the action twice, as first one does not do anything).

Do you get a flash of content of the page before it navigates to the login screen? I’ve got this in a reusable header that I was intending to put on all non-login pages. Wondering if one needs to do something extra to avoid the content being shown for the non-logged-in user

It redirects immediately for me. Just to be safe, I’ve set critical data to only be visible when the user is logged in and for me, most data is also displayed based on the logged in user.

Yeah, I also get a flash of content before the user is redirected away and I would much rather nothing load at all if the right user isn’t logged in. Is there some special way we’re supposed to achieve this?

1 Like

Ah, here is the correct solution: Use the “If user is logged out” workflow event

image

2 Likes

Topic is from 2017 emo :smile:

1 Like

WELCOME TO BUBBLE!!! Hooray.

You have to deactivate the debug_mode.