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
ce94a13d
Commit
ce94a13d
authored
Sep 24, 2018
by
Chavee Issariyapat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use group _key as a groupid instead of group name
parent
78146367
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
14 deletions
+26
-14
authhook/utils/getGroupID.js
+26
-14
No files found.
authhook/utils/getGroupID.js
View file @
ce94a13d
var
config
=
require
(
'config'
);
var
seneca
=
require
(
'seneca'
)({
log
:
'silent'
}).
client
({
port
:
config
.
get
(
'device_registry_port'
),
host
:
config
.
get
(
'device_registry_host'
)
});
var
getRole
=
require
(
'../checkClientRole'
).
getRole
function
getGroupID
(
token
,
client_id
)
{
var
role
=
getRole
(
token
)
if
(
role
)
{
if
(
role
.
hasOwnProperty
(
'groupId'
))
{
return
role
.
groupId
}
else
{
return
doDB
(
client_id
)
}
async
function
getGroupID
(
token
,
client_id
)
{
var
role
=
getRole
(
token
);
if
(
role
&&
role
.
hasOwnProperty
(
'groupId'
))
{
return
role
.
groupId
;
}
else
{
var
group
=
await
doDB
(
client_id
);
return
group
;
}
else
return
role
}
module
.
exports
.
getGroupID
=
getGroupID
function
doDB
(
client_id
)
{
var
groupId
=
'test'
return
groupId
}
\ No newline at end of file
return
new
Promise
((
resolve
,
reject
)
=>
{
seneca
.
act
(
'cmd:getGroupByClientid, clientid:'
+
client_id
,
function
(
err
,
res
)
{
if
(
err
)
reject
(
err
);
else
resolve
((
res
&&
res
.
result
&&
res
.
result
[
0
])?
res
.
result
[
0
]:
null
);
});
});
}
//Test
async
function
test
()
{
var
g
=
await
getGroupID
(
''
,
'aw9f0d2c-aliceclient'
);
console
.
log
(
g
);
}
test
();
\ No newline at end of file
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