Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
vernemq
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
stack
vernemq
Commits
e247d158
Commit
e247d158
authored
Feb 26, 2019
by
Chavee Issariyapat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clean up code
parent
aea22f6e
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
31 deletions
+6
-31
authhook/auth_on_subscribe.js
+1
-0
authhook/utils/getGroupID.js
+3
-2
authhook/utils/router.js
+2
-29
No files found.
authhook/auth_on_subscribe.js
View file @
e247d158
...
...
@@ -43,6 +43,7 @@ module.exports = function (options = {}) {
var
GGID
=
require
(
'./utils/getGroupID'
);
GGID
.
getGroupID
(
req
.
body
.
username
,
req
.
body
.
client_id
,
function
(
group
)
{
if
(
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
...
...
authhook/utils/getGroupID.js
View file @
e247d158
...
...
@@ -11,9 +11,9 @@ function getGroupID(token, client_id, callback) {
callback
(
role
.
groupId
);
}
else
{
doDB
(
client_id
,
function
(
group
)
{
doDB
(
client_id
,
function
(
group
id
)
{
if
(
group
)
callback
(
group
);
if
(
group
id
)
callback
(
groupid
);
else
callback
(
client_id
);
// fake group to isolate device
});
...
...
@@ -22,6 +22,7 @@ function getGroupID(token, client_id, callback) {
function
doDB
(
client_id
,
callback
)
{
seneca
.
act
(
'cmd:getGroupByClientid, clientid:'
+
client_id
,
function
(
err
,
res
)
{
if
(
err
)
callback
(
null
);
else
callback
((
res
&&
res
.
result
&&
res
.
result
[
0
])?
res
.
result
[
0
]:
null
);
});
...
...
authhook/utils/router.js
View file @
e247d158
...
...
@@ -15,6 +15,7 @@ function rewriteTopic(topic, op, groupid, clientid, output) {
return
modify
.
insertWordIntoTopic
(
topic
,
'!'
+
clientid
,
3
);
}
else
if
(
chunk
[
2
].
startsWith
(
'updated:'
))
{
return
modify
.
insertWordIntoTopic
(
topic
,
'!'
+
groupid
,
3
);
}
else
{
...
...
@@ -37,36 +38,8 @@ function rewriteTopic(topic, op, groupid, clientid, output) {
}
break
;
// if (chunk[1] == 'set' || chunk[1] == 'overset' || chunk[1] == 'get') {
// output.verb = chunk[1];
// return modify.insertWordIntoTopic(topic, ''+clientid, 2);
// }
// else if (chunk[1] == 'write' || chunk[1] == 'overwrite' || chunk[1] == 'read') {
// output.verb = chunk[1];
// return modify.insertWordIntoTopic(topic, groupid, 2);
// }
// else if (chunk[1] == 'changed') {
// if (op == 'pub') {
// if ( chunk.length > 2 )
// return modify.insertWordIntoTopic(topic, '!'+groupid, 2);
// else if ( chunk.length == 2 )
// return modify.insertWordIntoTopic(topic, '!'+clientid, 2);
// else return "";
// }
// else {
// if ( chunk.length > 2 )
// return modify.insertWordIntoTopic(topic, '!'+groupid, 2);
// else if ( chunk.length == 2 )
// return modify.insertWordIntoTopic(topic, '!'+clientid, 2);
// else return "";
// }
// }
// else return "";
case
'@private'
:
console
.
log
(
modify
.
insertWordIntoTopic
(
topic
,
'!'
+
clientid
,
1
));
//
console.log(modify.insertWordIntoTopic(topic, '!'+clientid, 1));
return
modify
.
insertWordIntoTopic
(
topic
,
'!'
+
clientid
,
1
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment