Difficuly limiting access to parts of app

I have a button that I want to hide or show depending on the users role. I have tried two different ways of doing this.

One I have created a role field in the user thing of the database, I have then put admin in that field and used a condition that says, when current users role is “admin” then the button shows up. This didn’t work. If I change the condition to when current users role is empty, then it works.

The second option I tried is to setup a field called is_admin, which required yes or no / true or false to be selected. If I manual enter yes into that field and then use a condition that says, when is_admin is yes then the button visible. The button doesn’t show up, but if I change the condition to when is_admin is no, even though it says yes in the field, the button will show.

Is this a bug or is there something I am missing?

1 Like

Make the button “Not visible on page load” by default. Then only show it if the user field admin = yes.

1 Like

I have deselected that, and have been playing around with it for the last little while with nil effect.

Can you please share a viewable copy of your app?

@Nocodify here is my app.

Is this the button you’re referring to?

If so, your DB setup looks fine. I can’t edit and make changes to test it out… but the user account you’re running on is an admin, so they SHOULD be able to click the button.

To test it out, create a user account that ISN’T an admin, or change the current one that you have to not be an admin.

Make sure the “This element is clickable” setting is checked, and that the condition is turned on.

Thanks, yes that is the button, I had changed it from when I first posted. It should say is_admin is yes.

@Nocodify, I have changed it back and you should be abel to see that it is not working.

14%20PM

Okay, so right now the element will never be visible. You have it as is not loading on page load, and the visible checkbox is unchecked.

So to fix this, leave it as is_admin “yes”

Then, make the “is visible” as checked.

So now, only admin’s will be able to see the button and therefore click it. Let me know if this fixes the issue.

@Nocodify Sorry I forgot to click the button, so I have now clicked the button and at least for me it is not showing up.

@Nocodify I have change the permission so you can now edit, let me know if you do and what you do.

So your issue was with your data privacy that you set up. It looks like you started to create a data privacy role for a user, but never got to finishing it. No user had access to view the admin field, meaning that that condition would never work.

I removed it, and now it works fine.

2 Likes

ah right, I am still working out all the privacy issues and how it works. Thank you for your help

No problem, if you don’t mind marking the solution as solved, so it can close.

If you need help auditing your privacy rules once you get them set up, feel free to PM me or reach out.

I certainly will do. Thank you again

Hi, you know if I can create a role table like this to show and hide sections and widgets in my app