I need to take a user role (i.e., Viewer versus User) into consideration when making queries. How can I check the role in a filter? I’m looking for something simple if possible, i.e. via a sql_on statement, unless templates are the only way to do it.
For example, suppose I have a column called “Clearance” in the database. I want Users to be able to see all rows in the database, but Viewers should only see those rows with a clearance value of “5” or less.
Is this doable?
Thanks.
This use case seems well-suited for user attributes and access filters, which provide row-level security by inserting conditions in the SQL WHERE clause.
Using the example given, we can use these steps:
<0, >=0, NULL
) whereas users in another group may only see values at or under 5 (we can use <=5
). access_filter: {
field: view_name.clearance_column
user_attribute: clearance_access
}