Commit f78abcd2 by Chavee Issariyapat

Merge branch 'alpha-test' of https://dev.nexpie.com/stack/vernemq into alpha-test

parents 410ac110 fe0fbce2
......@@ -33,10 +33,9 @@ module.exports = function (options = {}) {
checkRealDB(req.body.username, (err, decoded) => {
if (err) {
// Set Response
var getGroupID = require('./utils/getGroupID').getGroupID
getGroupID(req.body.username, req.body.client_id, (_id) => { // get groupID
// console.log(_id)
var _ftopic = require('./utils/getTopic').getTopic(topic, _id) // get topic where concat with groupID
var isShadow = require('./utils/getTopic').isShadow
if (isShadow(topic)) {
var _ftopic = require('./utils/getTopic').getTopic(topic, req.body.client_id) // get topic where concat with groupID
var response = {
'result': 'ok',
'modifiers': {
......@@ -58,7 +57,35 @@ module.exports = function (options = {}) {
res.send(response);
}
next();
})
}
else {
var getGroupID = require('./utils/getGroupID').getGroupID
getGroupID(req.body.username, req.body.client_id, (_id) => { // get groupID
// console.log(_id)
var _ftopic = require('./utils/getTopic').getTopic(topic, _id) // get topic where concat with groupID
var response = {
'result': 'ok',
'modifiers': {
'topic': _ftopic,
'qos': 0,
'retain': false
}
}
console.log(response)
if (typeof (authstatus) == 'undefined') {
// cache missed
authCheck(req.body.client_id, req.body.username, topic, function (result) {
cache.set(cachekey, result);
res.send(response);
});
}
else {
res.send(response);
}
next();
})
}
}
else {
console.log(decoded)
......
......@@ -38,10 +38,9 @@ module.exports = function (options = {}) {
checkRealDB(req.body.username, (err, decoded) => {
if (err) {
// Set Response
var getGroupID = require('./utils/getGroupID').getGroupID
getGroupID(req.body.username, req.body.client_id, (_id) => { // get groupID
// console.log(_id)
var _ftopic = require('./utils/getTopic').getTopic(topic, _id) // get topic where concat with groupID
var isShadow = require('./utils/getTopic').isShadow
if (isShadow(topic)) {
var _ftopic = require('./utils/getTopic').getTopic(topic, req.body.client_id) // get topic where concat with groupID
var _topic = [{ // setTopic for response
'topic': _ftopic,
'qos': 0
......@@ -63,7 +62,35 @@ module.exports = function (options = {}) {
res.send(response);
}
next();
})
}
else {
var getGroupID = require('./utils/getGroupID').getGroupID
getGroupID(req.body.username, req.body.client_id, (_id) => { // get groupID
// console.log(_id)
var _ftopic = require('./utils/getTopic').getTopic(topic, _id) // get topic where concat with groupID
var _topic = [{ // setTopic for response
'topic': _ftopic,
'qos': 0
}]
var response = {
'result': 'ok',
'topics': _topic
}
console.log(response)
if (typeof (authstatus) == 'undefined') {
// cache missed
authCheck(req.body.client_id, req.body.username, topic, function (result) {
cache.set(cachekey, result);
res.send(response);
});
}
else {
res.send(response);
}
next();
})
}
}
else {
console.log(decoded)
......
......@@ -16,4 +16,12 @@ function classifiedTopic(topic) {
} else if (topic.indexOf('@client') !== -1) {
return '@client'
}
}
\ No newline at end of file
}
function isShadow(topic) {
if (topic.indexOf('@shadow') !== -1) {
return true
}
else return false
}
module.exports.isShadow = isShadow
\ No newline at end of file
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