Commit b0008ed3 by zCaesar

fix

parent e46d316b
......@@ -30,6 +30,7 @@ function authCheck(client_id, token, password, callback) {
seneca.act('ms:tokenregistry, cmd:getAttributes, type:device, tokencode:' + token, function (err, res) {
console.log('result : ' + util.inspect(res.result, false, null, true))
if (res.result) {
console.log(res.result)
var token_profile = (res && res.result && res.result[0]) ? res.result[0] : {};
var mqttauth = {
clientid: client_id,
......@@ -103,7 +104,7 @@ module.exports = function (options = {}) {
// cache missed
authCheck(req.body.client_id, req.body.username, req.body.password, function (result) {
cache.set(cachekey, result);
if (!result) {
if (result) {
require('./redis/on_register').on_register_redis(req.body.client_id).then(status => {
console.log('redis:status: ' + status)
res.send({
......
......@@ -3,7 +3,7 @@ var redis = new Redis()
function on_message_redis(deviceid, payload) { // first time to access on authhook auth_on_register
return new Promise((resolve, reject) => {
if (deviceid.indexOf('mqtt') === 0 && deviceid.length !== 36) {
if (deviceid.indexOf('mqtt') === 0 || deviceid.length !== 36) {
console.log(deviceid)
resolve(true)
}
......
......@@ -3,7 +3,7 @@ var redis = new Redis()
function on_offline_redis(deviceid) { // first time to access on authhook auth_on_register
return new Promise((resolve, reject) => {
if (deviceid.indexOf('mqtt') === 0 && deviceid.length !== 36) {
if (deviceid.indexOf('mqtt') === 0 || deviceid.length !== 36) {
resolve(true)
}
else {
......
......@@ -3,7 +3,7 @@ var redis = new Redis()
function on_register_redis(deviceid) { // first time to access on authhook auth_on_register
return new Promise((resolve, reject) => {
if (deviceid.indexOf('mqtt') === 0 && deviceid.length !== 36) {
if (deviceid.indexOf('mqtt') === 0 || deviceid.length !== 36) {
resolve(true)
}
else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment