# Roles and securety

**URL:** <https://forum.bubble.io/t/roles-and-securety/245932>\
**Category:** Database\
**Created:** [February 8, 2023, 3:11pm UTC](https://forum.bubble.io/t/roles-and-securety/245932 "2023-02-08T15:11:23Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Orbit](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/orbit/32/253365_2.png) [@Orbit](https://forum.bubble.io/u/Orbit)\
**Post date:** [February 8, 2023, 3:11pm UTC](https://forum.bubble.io/t/roles-and-securety/245932/1 "2023-02-08T15:11:23Z")

</div>

Hello, i have set up roles “Admin, User, Guest” and i have a page called “dashboard” that is for admins to view stats etc. I have made a workflow that says` if user is not admin send them to index page` however when in incognito mode i still see the page for a split second with all the info etc and must be easy for someone with more knowledge to bypass.

My question is, how do you secure these pages? 😇

---

<div class="post-metadata">

**Author:** ![dorilama](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/dorilama/32/226878_2.png) [@dorilama](https://forum.bubble.io/u/dorilama)\
**Post date:** [February 8, 2023, 3:22pm UTC](https://forum.bubble.io/t/roles-and-securety/245932/2 "2023-02-08T15:22:23Z")

</div>

The first thing is obviously to secure the data with privacy rules. Any request to data without the right privilege should return empty. If a random user, not admin, can see the data on the page you need to set privacy rules.

After that if you don’t have “on load” workflows that need data from the client your redirect (still “on load”) should trigger a server redirect. If it’s not happening check your workflows.

---

<div class="post-metadata">

**Author:** ![Orbit](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/orbit/32/253365_2.png) [@Orbit](https://forum.bubble.io/u/Orbit)\
**Post date:** [February 8, 2023, 3:23pm UTC](https://forum.bubble.io/t/roles-and-securety/245932/3 "2023-02-08T15:23:13Z")

</div>

I dont really understand this part “After that if you don’t have “on load” workflows that need data from the client your redirect (still “on load”) should trigger a server redirect. If it’s not happening check your workflows.”

---

<div class="post-metadata">

**Author:** ![dorilama](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/dorilama/32/226878_2.png) [@dorilama](https://forum.bubble.io/u/dorilama)\
**Post date:** [February 8, 2023, 3:29pm UTC](https://forum.bubble.io/t/roles-and-securety/245932/4 "2023-02-08T15:29:05Z")

</div>

for example you have a page admin\_dashboard:  
if you have a workflow that get data from url when page loads then bubble will serve de page.  
if you only have a workflow with a condition `only when current user role is not admin` and a single action `go to page normal_dashboard` then bubble should redirect directly to normal\_dashboard from the server and admin\_dashboard is not even served to the user.

---

<div class="post-metadata">

**Author:** ![dorilama](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/dorilama/32/226878_2.png) [@dorilama](https://forum.bubble.io/u/dorilama)\
**Post date:** [February 8, 2023, 3:30pm UTC](https://forum.bubble.io/t/roles-and-securety/245932/5 "2023-02-08T15:30:02Z")

</div>

Of course you still need to set privacy rules, that’s the most important thing.

---

<div class="post-metadata">

**Author:** ![adamhholmes](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/adamhholmes/32/100510_2.png) [@adamhholmes](https://forum.bubble.io/u/adamhholmes)\
**Post date:** [February 8, 2023, 3:30pm UTC](https://forum.bubble.io/t/roles-and-securety/245932/6 "2023-02-08T15:30:10Z")

</div>

Also, make everything on the page ‘not visible’ by default (just in case), and only make it visible to the correct Users.

As an extra security layer, add the same condition to all the workflows on the page.

---

<div class="post-metadata">

**Author:** ![Orbit](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/orbit/32/253365_2.png) [@Orbit](https://forum.bubble.io/u/Orbit)\
**Post date:** [February 8, 2023, 3:39pm UTC](https://forum.bubble.io/t/roles-and-securety/245932/7 "2023-02-08T15:39:24Z")

</div>

Is that possible to do to the whole page or do i have to do it for each group?

---

<div class="post-metadata">

**Author:** ![Orbit](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/orbit/32/253365_2.png) [@Orbit](https://forum.bubble.io/u/Orbit)\
**Post date:** [February 8, 2023, 3:40pm UTC](https://forum.bubble.io/t/roles-and-securety/245932/8 "2023-02-08T15:40:48Z")

</div>

Here is my workflow:  
 ![Screenshot 2023-02-08 at 16.39.59](https://us1.discourse-cdn.com/bubble/original/3X/d/b/db69c4881cce5411a94f51adea6345c6fe331c71.png)

I believe i have the settings you described but Bubble still loads the Admin dashboards and then re-direct to index?

---

<div class="post-metadata">

**Author:** ![adamhholmes](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/adamhholmes/32/100510_2.png) [@adamhholmes](https://forum.bubble.io/u/adamhholmes)\
**Post date:** [February 8, 2023, 3:52pm UTC](https://forum.bubble.io/t/roles-and-securety/245932/9 "2023-02-08T15:52:07Z")

</div>

Assuming everything on the page is grouped inside a main container, just do it for that - if not then you need to do it for every top-leve container.

---

<div class="post-metadata">

**Author:** ![dorilama](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/dorilama/32/226878_2.png) [@dorilama](https://forum.bubble.io/u/dorilama)\
**Post date:** [February 8, 2023, 4:06pm UTC](https://forum.bubble.io/t/roles-and-securety/245932/10 "2023-02-08T16:06:07Z")

</div>

You have exactly the settings that prevent a server redirect.

> [@dorilama](#):
>
> if you have a workflow that get data from url when page loads then bubble will serve de page.

If you have any workflow on page load that uses client side data (eg. page url) bubble can’t do a server redirect.

> [@dorilama](#):
>
> if you only have a workflow with a condition `only when current user role is not admin` and a single action `go to page normal_dashboard` then bubble should redirect directly to normal\_dashboard from the server and admin\_dashboard is not even served to the user.

This should be the only workflow on page load (it needs to be on page load, not do when condition is true)

---

<div class="post-metadata">

**Author:** ![Orbit](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/orbit/32/253365_2.png) [@Orbit](https://forum.bubble.io/u/Orbit)\
**Post date:** [February 8, 2023, 4:27pm UTC](https://forum.bubble.io/t/roles-and-securety/245932/11 "2023-02-08T16:27:05Z")

</div>

Oh okey… i followed this tutorial [How to build a simple dashboard in Bubble: Dashboard tutorial 1/3 - YouTube](https://www.youtube.com/watch?v=4aabccslG5Q) to make the dashboard and that uses the page load function… How can i do that in a efficient way?

---

<div class="post-metadata">

**Author:** ![dorilama](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/dorilama/32/226878_2.png) [@dorilama](https://forum.bubble.io/u/dorilama)\
**Post date:** [February 8, 2023, 4:40pm UTC](https://forum.bubble.io/t/roles-and-securety/245932/12 "2023-02-08T16:40:25Z")

</div>

Set privacy rules, and as Adam said add conditions to the workflows and make the elements hidden by default and visible only to the right user.
