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
a23d9730
Commit
a23d9730
authored
Dec 03, 2018
by
zCaesar
Browse files
Options
Browse Files
Download
Plain Diff
redis
parents
babf826c
9c233f79
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
1 deletions
+52
-1
authhook/.gitignore
+1
-0
authhook/auth_on_register.js
+50
-0
authhook/on_unsubscribe.js
+1
-1
authhook/package-lock.json
+0
-0
No files found.
authhook/.gitignore
View file @
a23d9730
.DS_Store
node_modules/
config/*.json
*.rdb
authhook/auth_on_register.js
View file @
a23d9730
...
...
@@ -101,6 +101,7 @@ module.exports = function (options = {}) {
}
var
cachekey
=
'auth:'
+
req
.
body
.
client_id
+
':'
+
req
.
body
.
username
+
':'
+
req
.
body
.
password
;
var
authstatus
=
cache
.
get
(
cachekey
);
<<<<<<<
HEAD
// if (typeof (authstatus) == 'undefined') {
// // cache missed
// authCheck(req.body.client_id, req.body.username, req.body.password, function (result) {
...
...
@@ -157,6 +158,51 @@ module.exports = function (options = {}) {
}
else
{
res
.
send
({
result
:
{
error
:
'not allowed'
}
=======
if
(
typeof
(
authstatus
)
==
'undefined'
)
{
// cache missed
authCheck
(
req
.
body
.
client_id
,
req
.
body
.
username
,
req
.
body
.
password
,
function
(
result
)
{
cache
.
set
(
cachekey
,
result
);
if
(
result
)
{
require
(
'./redis/on_register'
).
on_register_redis
(
req
.
body
.
client_id
).
then
(
status
=>
{
console
.
log
(
'redis:status: '
+
status
)
if
(
status
)
{
res
.
send
({
result
:
'ok'
});
}
else
{
res
.
send
({
result
:
{
error
:
'not allowed'
}
});
}
})
}
else
{
res
.
send
({
result
:
{
error
:
'not allowed'
}
});
}
// const util = require('util')
// console.log(util.inspect(status, false, null, true))
});
}
else
{
if
(
authstatus
)
{
require
(
'./redis/on_register'
).
on_register_redis
(
req
.
body
.
client_id
).
then
(
status
=>
{
console
.
log
(
'redis:status: '
+
status
)
if
(
status
)
{
res
.
send
({
result
:
'ok'
});
}
else
{
res
.
send
({
result
:
{
error
:
'not allowed'
}
});
}
})
}
else
{
res
.
send
({
result
:
{
error
:
'not allowed'
}
>>>>>>>
9
c233f79215090b0fd648f8b8b8061447ed746dc
});
}
})
...
...
@@ -164,7 +210,11 @@ module.exports = function (options = {}) {
}
else
{
res
.
send
({
<<<<<<<
HEAD
result
:
{
error
:
'not allowed'
}
=======
result
:
'no'
>>>>>>>
9
c233f79215090b0fd648f8b8b8061447ed746dc
});
next
();
}
...
...
authhook/on_unsubscribe.js
View file @
a23d9730
...
...
@@ -11,7 +11,7 @@ module.exports = function(options = {}) {
if
(
decoded
)
{
if
(
decoded
.
role
===
'realtimedb'
)
{
response
=
{
'result'
:
'ok'
}
response
=
{
result
:
'ok'
}
}
else
response
=
{
result
:
{
error
:
'not allowed'
}
}
res
.
send
(
response
);
...
...
authhook/package-lock.json
View file @
a23d9730
This diff is collapsed.
Click to expand it.
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