You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
when use Ponte as embedded in nodejs code and i want to authorize for publishing, client.user is not found in client object while publish payload in MQTT.
client.id is Ok but about client.user it is not included and it's undefined.
you can find whole code below;
constdebug=require('debug')('iok-express:ponte');constponte=require('ponte');varconfig=require('../config/ponte.js');varmongoose=require('mongoose');varThing=require("../models/thing");// Accepts the connection if the username and password are validvarauthenticate=function(client,username,password,callback){Thing.findOne({clientid: client.id},function(err,things){if(err){console.log('Quering thing failed.');console.log(err);callback(null,false);return;}if(!things){console.log("ClientID Not found, Client ID:"+client.id);callback(null,false);return;}if(username==things.config.username&&password==things.config.password){console.log('Successful MQTT credintial. Client ID:'+client.id);callback(null,true);return;}else{console.log('Unsuccessful MQTT credintial. Client ID:'+client.id+' ,Username:'+username+' ,Password:'+password);callback(null,false);}});}varauthorizePublish=function(client,topic,payload,callback){callback(null,client.id==topic.split('/')[1]);}varauthorizeSubscribe=function(client,topic,callback){callback(null,client.id==topic.split('/')[1]);}config.mqtt.authenticate=authenticate;config.mqtt.authorizePublish=authorizePublish;config.mqtt.authorizeSubscribe=authorizeSubscribe;varserver=ponte(config);server.on("updated",function(resource,buffer){console.log("Resource Updated",resource,buffer);});
The text was updated successfully, but these errors were encountered:
when use Ponte as embedded in nodejs code and i want to authorize for publishing, client.user is not found in client object while publish payload in MQTT.
client.id is Ok but about client.user it is not included and it's undefined.
you can find whole code below;
The text was updated successfully, but these errors were encountered: