I have followed this guide,Because I wanted to verify the user's credentials at the time the user subscribed and published, but I couldn't get the user name.
// In this case the client authorized as alice can publish to /users/alice taking
// the username from the topic and verifing it is the same of the authorized user
var authorizePublish = function(client, topic, payload, callback) {
console.log(client.user) // undefined
callback(null, client.user == topic.split('/')[1]);
}
// In this case the client authorized as alice can subscribe to /users/alice taking
// the username from the topic and verifing it is the same of the authorized user
var authorizeSubscribe = function(client, topic, callback) {
console.log(client.user) // undefined
callback(null, client.user == topic.split('/')[1]);
}
So I changed the code so that I could get the user name.
I have followed this guide,Because I wanted to verify the user's credentials at the time the user subscribed and published, but I couldn't get the user name.
So I changed the code so that I could get the user name.