Dashboard 2.0 - Admin-only Pages with FlowFuse Auth
A flow to utilise the FlowFuse msg._client.user
object available when running Dashboard 2.0 on FlowFuse Cloud.
Here, we wire a ui-event
node (which emits each time a user views a page) into a switch node, check the user.username
against a known list of admin users, and then branch to a change
node and define a message for our ui-control
node to dynamically show content, in this case an "Admin" page, when appropriate
[{"id":"21df966fb52c173a","type":"ui-event","z":"cb5b78e336d1cf6c","ui":"c851adb9b2a29c9e","name":"","x":100,"y":60,"wires":[["32fbea6828a3a587","c70967b33e3d55c3"]]},{"id":"c70967b33e3d55c3","type":"switch","z":"cb5b78e336d1cf6c","name":"","property":"_client.user.username","propertyType":"msg","rules":[{"t":"eq","v":"admin-user","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":250,"y":60,"wires":[["bf8ea351c63dda23"],[]]},{"id":"bf8ea351c63dda23","type":"change","z":"cb5b78e336d1cf6c","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"pages\":{\"show\":[\"Admin View\"]}}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":400,"y":60,"wires":[["b9aceae5f7cbf1c3"]]},{"id":"b9aceae5f7cbf1c3","type":"ui-control","z":"cb5b78e336d1cf6c","name":"","ui":"c851adb9b2a29c9e","events":"all","x":560,"y":60,"wires":[[]]},{"id":"c851adb9b2a29c9e","type":"ui-base","name":"UI Name","path":"/dashboard","includeClientData":true,"acceptsClientConfig":["ui-notification","ui-control"]}]