Commit 9c233f79 by Chavee Issariyapat

fix vernemq error when authhook reject client

parent 8ac40526
.DS_Store .DS_Store
node_modules/ node_modules/
config/*.json config/*.json
*.rdb
...@@ -34,7 +34,7 @@ module.exports = function (options = {}) { ...@@ -34,7 +34,7 @@ module.exports = function (options = {}) {
if (decoded) { if (decoded) {
if (decoded.role === 'realtimedb') response = { 'result': 'ok' } if (decoded.role === 'realtimedb') response = { 'result': 'ok' }
else response = { 'result': 'no' } else response = { result: {error: 'not allowed'} }
res.send(response); res.send(response);
next(); next();
} }
...@@ -65,7 +65,7 @@ module.exports = function (options = {}) { ...@@ -65,7 +65,7 @@ module.exports = function (options = {}) {
next(); next();
} }
else { else {
res.send({ "result": "no" }); res.send({ result: {error: 'not allowed'} });
next(); next();
} }
}); });
...@@ -75,7 +75,7 @@ module.exports = function (options = {}) { ...@@ -75,7 +75,7 @@ module.exports = function (options = {}) {
} }
else { else {
res.send({ "result": "no" }); res.send({ result: {error: 'not allowed'} });
next(); next();
} }
} }
......
...@@ -109,17 +109,17 @@ module.exports = function (options = {}) { ...@@ -109,17 +109,17 @@ module.exports = function (options = {}) {
console.log('redis:status: ' + status) console.log('redis:status: ' + status)
if (status) { if (status) {
res.send({ res.send({
"result": "ok" result: 'ok'
}); });
} else { } else {
res.send({ res.send({
"result": "no" result: {error: 'not allowed'}
}); });
} }
}) })
} else { } else {
res.send({ res.send({
"result": "no" result: {error: 'not allowed'}
}); });
} }
// const util = require('util') // const util = require('util')
...@@ -132,17 +132,17 @@ module.exports = function (options = {}) { ...@@ -132,17 +132,17 @@ module.exports = function (options = {}) {
console.log('redis:status: ' + status) console.log('redis:status: ' + status)
if (status) { if (status) {
res.send({ res.send({
"result": "ok" result: 'ok'
}); });
} else { } else {
res.send({ res.send({
"result": "no" result: {error: 'not allowed'}
}); });
} }
}) })
} else { } else {
res.send({ res.send({
"result": "no" result: {error: 'not allowed'}
}); });
} }
} }
...@@ -150,7 +150,7 @@ module.exports = function (options = {}) { ...@@ -150,7 +150,7 @@ module.exports = function (options = {}) {
} }
else { else {
res.send({ res.send({
"result": "no" result: 'no'
}); });
next(); next();
} }
......
...@@ -29,7 +29,7 @@ module.exports = function (options = {}) { ...@@ -29,7 +29,7 @@ module.exports = function (options = {}) {
if (decoded) { if (decoded) {
if (decoded.role === 'realtimedb') response = { 'result': 'ok' } if (decoded.role === 'realtimedb') response = { 'result': 'ok' }
else response = { 'result': 'no' } else response = { result: {error: 'not allowed'} }
res.send(response); res.send(response);
next(); next();
} }
...@@ -56,14 +56,14 @@ module.exports = function (options = {}) { ...@@ -56,14 +56,14 @@ module.exports = function (options = {}) {
next(); next();
} }
else { else {
res.send({ "result": "no" }); res.send({ result: {error: 'not allowed'} });
next(); next();
} }
}); });
} }
} }
else { else {
res.send({ "result": "no" }); res.send({ result: {error: 'not allowed'} });
next(); next();
} }
} }
......
...@@ -11,9 +11,9 @@ module.exports = function(options = {}) { ...@@ -11,9 +11,9 @@ module.exports = function(options = {}) {
if (decoded) { if (decoded) {
if (decoded.role === 'realtimedb') { if (decoded.role === 'realtimedb') {
response = { 'result': 'ok' } response = { result: 'ok' }
} }
else response = { 'result': 'no' } else response = { result: {error: 'not allowed'} }
res.send(response); res.send(response);
next() next()
} }
...@@ -28,7 +28,7 @@ module.exports = function(options = {}) { ...@@ -28,7 +28,7 @@ module.exports = function(options = {}) {
"topics": [_ftopic] "topics": [_ftopic]
} }
} }
else response = { 'result': 'no' } else response = { result: {error: 'not allowed'} }
if (options.debug) { if (options.debug) {
console.log('on_unsubscribe-------------'); console.log('on_unsubscribe-------------');
......
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