Commit f04b3be6 by zCaesar

Merge branch 'alpha-v2' into 'master'

Edit Register

See merge request !4
parents 4e9efab1 e0d42e97
......@@ -2,7 +2,7 @@ var validator = require('./validator');
var config = require('config');
// var seneca = require('seneca')({log: 'silent'}).client({ port: config.get('device_registry_port'), host: config.get('device_registry_host') });
var seneca = require('seneca')({log: 'silent'}).client({ port: config.get('token_registry_port'), host: config.get('token_registry_host') });
var seneca = require('seneca')({ log: 'silent' }).client({ port: config.get('token_registry_port'), host: config.get('token_registry_host') });
// https://github.com/isaacs/node-lru-cache
var LRU = require("lru-cache"),
......@@ -17,23 +17,27 @@ var debug = false;
function authCheck(client_id, token, password, callback) {
const util = require('util')
// console.log(util.inspect(myObject, false, null, true));
if (require('jwt-verify').verify(token)) { // auth realtimedb by token
// console.log('jwt-result:' + util.inspect(require('jwt-verify').verify(token), false, null, true))
if (require('jwt-verify').verify(token).res) { // auth realtimedb by token
callback(true);
}
else {
if (require('jwt-verify').verify(token)) callback(true) // auth client device by token
else {
seneca.act('ms:tokenregistry, cmd:getAttributes, type:device, tokencode:'+token, function(err,res) {
if (!err && res) {
var token_profile = (res&&res.result&&res.result[0])?res.result[0]:{};
// console.log('token :' + token)
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) {
var token_profile = (res && res.result && res.result[0]) ? res.result[0] : {};
var mqttauth = {
clientid : client_id,
token : token,
password : password
clientid: client_id,
token: token,
password: password
};
callback( validator.auth_connect(mqttauth, token_profile) );
callback(validator.auth_connect(mqttauth, token_profile));
}
else {
callback(false);
......@@ -77,7 +81,7 @@ function authCheck(client_id, token, password, callback) {
// callback(false);
// }
// });
}
}
}
......
......@@ -37,7 +37,6 @@ module.exports = function (options = {}) {
var GGID = require('./utils/getGroupID');
GGID.getGroupID(req.body.username, req.body.client_id, function (group) {
console.log(group);
var _ftopic = require('./utils/router').rewriteTopic(topic, 'sub', group, req.body.client_id) // get topic where concat with groupID
var _topic = [{ // setTopic for response
'topic': _ftopic,
......
{
"device_registry_host" : "alpha.nexpie.io",
"device_registry_host" : "localhost",
"device_registry_port" : 8990,
"token_registry_host" : "alpha.nexpie.io",
"token_registry_host" : "localhost",
"token_registry_port" : 8790,
"auth_on_register_debug" : true,
......
......@@ -438,8 +438,8 @@
}
},
"jwt-verify": {
"version": "git+https://nexpienpm:CCqLQjg4ytvzN7QbssUV@dev.nexpie.com/npm/jwt-verify.git#2652fe32eb15f1e1f05bc31aa98f5a7c10d049e3",
"from": "git+https://nexpienpm:CCqLQjg4ytvzN7QbssUV@dev.nexpie.com/npm/jwt-verify.git#issuer",
"version": "git+https://nexpienpm:CCqLQjg4ytvzN7QbssUV@dev.nexpie.com/npm/jwt-verify.git#c9692da3fd11464e9270acd0c47f289648119ec9",
"from": "git+https://nexpienpm:CCqLQjg4ytvzN7QbssUV@dev.nexpie.com/npm/jwt-verify.git",
"requires": {
"config": "^2.0.1",
"jsonwebtoken": "^8.3.0"
......
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