Restrict access to a page if the user is not logged in

Ah, ok, sorry.

So you would select the Navigation tab and choose Go to page …

2 Likes

For me the redirect isnt instant. It waits for the page to fully load and then redirects. Is there no option like ‘When page is not loaded’ instead of When page is loaded?

2 Likes

Can you show a screenshot of he workflow? Also, not sure I understand what a ‘page is not loaded’ event would do…

I think the action will only do things when the page is fully loaded. In these cases, that is not neccesary. I dont want to wait for the page to be loaded to redirect, it should just redirect immidiately.

These are the workflows on that page:

When I log out of my application currently i can still stay on the same page and view the “inner page” information which should only be accessed if logged in.

Is there a global setting somewhere to redirect to Index?

What if the user looses their session?

I do it with a workflow on the log out button. Log the user out > navigate to page. Or on page load > if user is not logged in > navigate to page. Third way is if contents is in a group > when user is logged out > group is not visible & show login popup

1 Like

As above. And on page load check for the user being logged in.

1 Like

“check on page load” then needs to be defined on every page right?

1 Like

I have put the Event in a header used on every page, and added a constraint so that there is no redirect if the user is already on the index or login page:

However, I’m having the problem mentioned above. When logged out and manually entering the URL to a page that is not accessible to users that are not logged in, the page is loaded and visible for 2-4 secs before the redirect is executed.

I tried to quit the browser and tried again, and with another browser on another computer. Still same result.

What if by default you have a big white shape (maybe with a loading icon) covering the full page (or a popup that blurs out the background)? When logged in > hide element. Obviously it’s not a direct solution to that 2-4 second lag, but it works with it. Users who have access see it as well, but again, you can have a loading message.

4 Likes

I’ll check the UX on that. Thanks!

Hi. I am also experiencing exactly this problem, in the manner you describe. Did you ever manage to find a solution to this problem?

Thanks

1 Like

I tried using 2 method, you can try any of them,
Both work well,

1.) Add New Event > General > Do When Condition Is True > When Current User Isn’t Logged In > Add Action > Navigation > Go To Page… > Index.

2.) Add New Event > General > Do When Condition Is True > When Current User Isn’t Logged In > Element Action > Show > Pop-Up Login
( Here you need to create new reusable pop-up, which has only Email, Password, login button and Go Home Button, Pop-up Can’t be closed by Esc, Grayout Blur=10 , Grayout Color = 90 , button go home navigates to inxed, and if user log’s in hide the pop-up no navigation.)

1 Like

@emmanuel
How about if there is an action called pre loading the page ? just a suggestion

4 Likes

Hey Everyone,

Just to let you know in addition to the page redirect, if you want to keep the data hidden you need to setup conditionals as well. So what I did was Group all of my elements into what I call a Page Group. Then I set the condition of that master group to say that the Current User must be logged in. Like so

All my elements in a page group
image

Only show when Current User is Logged in
image

3 Likes

bump!
I’ve created a reusable header panel with a workflow condition that checks if the current user isn’t logged in, then redirects to the login page. I am hoping this would be processed on the server (server side redirect), but Bubble waits for the page to load (client side redirect). How can I achieve a server-side redirect?

2 Likes

Hi,
May be you have set the page Type of content to be user or anything else.
I hope, login does not have any type of content. Just set as empty.

image

Run the validation on page load

I solved this problem by using “User is logged out” workflow action rather than “Do when condition is true” workflow action.

3 Likes

hello good afternoon i have this same problem of access restriction. when the user is not logged in.
could you explain to me how you solved this problem