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 = {}) { ...@@ -33,10 +33,9 @@ module.exports = function (options = {}) {
checkRealDB(req.body.username, (err, decoded) => { checkRealDB(req.body.username, (err, decoded) => {
if (err) { if (err) {
// Set Response // Set Response
var getGroupID = require('./utils/getGroupID').getGroupID var isShadow = require('./utils/getTopic').isShadow
getGroupID(req.body.username, req.body.client_id, (_id) => { // get groupID if (isShadow(topic)) {
// console.log(_id) var _ftopic = require('./utils/getTopic').getTopic(topic, req.body.client_id) // get topic where concat with groupID
var _ftopic = require('./utils/getTopic').getTopic(topic, _id) // get topic where concat with groupID
var response = { var response = {
'result': 'ok', 'result': 'ok',
'modifiers': { 'modifiers': {
...@@ -58,7 +57,35 @@ module.exports = function (options = {}) { ...@@ -58,7 +57,35 @@ module.exports = function (options = {}) {
res.send(response); res.send(response);
} }
next(); 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 { else {
console.log(decoded) console.log(decoded)
......
...@@ -38,10 +38,9 @@ module.exports = function (options = {}) { ...@@ -38,10 +38,9 @@ module.exports = function (options = {}) {
checkRealDB(req.body.username, (err, decoded) => { checkRealDB(req.body.username, (err, decoded) => {
if (err) { if (err) {
// Set Response // Set Response
var getGroupID = require('./utils/getGroupID').getGroupID var isShadow = require('./utils/getTopic').isShadow
getGroupID(req.body.username, req.body.client_id, (_id) => { // get groupID if (isShadow(topic)) {
// console.log(_id) var _ftopic = require('./utils/getTopic').getTopic(topic, req.body.client_id) // get topic where concat with groupID
var _ftopic = require('./utils/getTopic').getTopic(topic, _id) // get topic where concat with groupID
var _topic = [{ // setTopic for response var _topic = [{ // setTopic for response
'topic': _ftopic, 'topic': _ftopic,
'qos': 0 'qos': 0
...@@ -63,7 +62,35 @@ module.exports = function (options = {}) { ...@@ -63,7 +62,35 @@ module.exports = function (options = {}) {
res.send(response); res.send(response);
} }
next(); 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 { else {
console.log(decoded) console.log(decoded)
......
...@@ -16,4 +16,12 @@ function classifiedTopic(topic) { ...@@ -16,4 +16,12 @@ function classifiedTopic(topic) {
} else if (topic.indexOf('@client') !== -1) { } else if (topic.indexOf('@client') !== -1) {
return '@client' 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