Closed RobertoBiundo closed 7 years ago
you need to setup the authorize callbacks, and store the username inside the client if you need it.
how do i mach the client in the on publish call to the ones i saved? is there a reliable id to do so?
Ohh...i see...thanks. I found it already some code for future reference
server.authenticate = function (client, username, password, callback) {
client.user = username; // store username here
callback(null, true); // authenticate user before sending true
}
server.on('published', function (packet, client) {
// client will contain the userName client.user
}
When the user authenticates he uses a userName and password. Example from mosca
mosquitto_pub -h localhost -m 123 -t topic -u user@name.com -P 1234
is there a way to obtain this userName on the on Publish
server.on('published', function (packet, client) { }
i checked the client object but i can't seem to find anything that would give me his name. I need this for further processing of the package.
Any advice?