Managing user data with the {{user.email}} variable
Last updated
Was this helpful?
Last updated
Was this helpful?
The {{user.email}}
variable can be used in cases when you need to load data that belongs to a particular user or manage component visibility based on specific user roles. Check out the sections below to review these cases.
Let's say you want users to have access only to the data specific to them (for example, about their orders) based on their email. This is how you can do that
First, create an action that will load the data of the current user. It can be an SQL Query action step referencing the current user email:
Turn on the Transform result toggle and specify there return {{data[0]}}
, as the action will return an array of users with only a single item in it.
Now, after loading your user, you can fill their information (for example, about their orders) using a Load Table action step.
In the Filters section of the Load Table action, configure a filter that will reference the action from step 1 holding additional information about the current user:
id = {{actions.getUser.id}}
That's it! Now when different users login into the application, they will see only their orders' data.
Let's say you want to make certain components visible only to specific user roles - you can do that using the Condition setting of a component. We'll show how you can do that reviewing the use case of a Text input component visible only to the Admin.
In our case, we want the Admins of the workspace to be able to perform the search by customers and look for specific customer records. For this purpose, we've added a Text input component to the working area.
Next, to set component visibility we've specified the following condition in the component's Condition setting:
And that's it! Now, any user with the Admin role will be able to see the customer search input, while for regular users the component will be hidden.