Filter data using profile email

  • I have a security dashboard wherein I want users to review only the data that belongs to them.
    Best way I can think of is by using the login profile email. 
    Also, Possible to add exceptions to few admin accounts that can be bypassed? 

    anyone how I can achieve this? Appreciate your help! 
0 1 48
1 REPLY 1

I think the way I'd go about this is by using referencing user attributes in Liquid in a sql_always_where in the explore.

(note: Community doesn't like liquid tags, so please replace all of my parentheses with curly braces {})

If you have an email field, you could write something like this:

sql_always_where: (( _user_attributes['email'] )) = ${user.email} ;;


You can use Liquid to write in a few admin exceptions: 

 

sql_always_where: 
(% if user_attributes['email'] == 'superuser@example.com' or user_attributes['email'] == 'admin@example.com' %) 1=1 (% else %) (( _user_attributes['email'] ))
= ${user.email} (% endif %);;