Search code examples
node.jsiotnode-red

Node Red UI - How to get logged user name?


I want to save the logged user name of Node Red UI in database.

I get some inspiration from here https://nodered.org/docs/configuration and implemented the user authentication for Node red editor and node red ui as well and its working fine.

Node Red Editor - User Authentication:

adminAuth: {
type: "credentials",
users: [{
    username: "admin",
    password: "$2a$08$zZWtXTja0fB1pzD4sHCMyOCMYz2Z6dNbM6tl8sJogENOMcxWV9DN.",
    permissions: "*"
}]},

Node Red UI - User Authentication:

httpNodeAuth: {user:"user",pass:"$2a$08$zZWtXTja0fB1pzD4sHCMyOCMYz2Z6dNbM6tl8sJogENOMcxWV9DN."},

I want to update table in database based on user input and i want to know who was updated that table So i want the logged user name of dashboard. From where i could get this?

Thanks in advance.


Solution

  • This is not possible at the moment.

    Given you can only define one user for the httpNodeAuth it's always going to be that user.

    For the editor it doesn't make sense to know who the editor is, unless you are trying to track who makes changes to the flow. But that would require you to write a custom storage module anyway.

    Also worth pointing out that the Dashboard UI is not multi user, even if you could authenticate multiple users, they do not have separate sessions, any update will appear to all browsers.