I have secured the acces of Node RED by setting up nginx. Then, i wanted to know the username of the person connected to the dashboard. So i added a middleware to the settings.js file. The code is below
Now i want to get the username to the node red flows, but i don't know how to do it. I tried to use functionGlobalContext, but i figured that the list just update at the launch of node red. So when another user connect to the dashboard, the variable doesn't get refresh, and the variable in node red says "undefined".
Is there a way to store the current username in a global (or flow) variable, and have it automatically update whenever a new user connects to the dashboard?
I'm trying to get a guest in a slightly different way, but I don't know if it's good. Maybe the code from the description will give you some hints. Note: it completely blocks the dashboard if there is no user, this may be undesirable.