Understanding Bubble Security for Logged-In Areas
Here's a super quick Bubble security tip for you. Imagine I've got an app, many no-code SaaS apps built with Bubble.io are going to have an area like this which is part of my app that I don't want to show to users who aren't logged in. I only want to show this to users who are logged in but there'll be parts of my app that I want to show to users who aren't logged in such as a registration or login form. So my app is split between a logged in area and a logged out area.
Choosing the Right Approach for User Access Control
Now what and how is the right way to go about this? Well there are two options and one is the one to go for. So we've got a do when statement so do when current user is logged out send them to the index page that's where I could put a registration form I could put a login form or I've got the user is logged out so that's the difference between selecting that option there or a do when condition is true statement.
The Crucial Difference in Redirect Methods
Now there is a huge difference between these two which is what sort of redirect happens when you use a user is logged out statement that occurs before Bubble loads in the page content it's known as a 302 redirect it happens server-side but when you run a statement such as this you may experience that Bubble loads in some of the page content before this statement is true or Bubble detects that the statement is true and then you run this workflow here.
Protecting User Data and UI Elements
Now to underline all this the only way to properly protect data in your Bubble database is to set up the appropriate privacy rules but if you want to protect UI like a dashboard to your users and you don't want logged out users to ever access that dashboard then you should be using this statement here user is logged out and then send them to a page and that is the correct way to do it with the server-side redirect without any of the page content you might want to protect loading into the user's browser.
Conclusion and Additional Resources
If you've liked this video we'd appreciate if you could subscribe and give it a like on YouTube and we've got over 160 Bubble tutorial videos now we're basically churning out one video a day and you can find all of them some which you cannot find on YouTube you can find all of them at planetnocode.com