Reference2 min read
User identity in flows
Read msg._client.user and check roles before sensitive flow actions.
On this page
Inspecting msg._client.user in flows
Whenever a signed-in user interacts with a FlowFuse Dashboard 2.0 widget through NR Connect, the plugin verifies their signed identity and populates msg._client.user:
msg._client.userjson
{
"userId": "usr_9f3a2c1e",
"email": "operator@example.com",
"name": "Alex Rivera",
"role": "operator"
}Use a switch or function node to audit who triggered a command, log operator actions, or restrict sensitive buttons (like equipment resets) to Admins only:
Check admin role (Function node)javascript
const user = msg._client?.user;
if (!user || user.role !== "admin") {
return [null, {
payload: `Access denied for ${user?.email || "anonymous"} (admin required)`
}];
}
msg.payload = { command: "restart", requestedBy: user.email };
return [msg, null];