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
c911192b
Commit
c911192b
authored
Nov 05, 2018
by
zCaesar
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'alpha-v2' into 'master'
edit datenow See merge request
!7
parents
f50cf834
fcb4408f
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
3 deletions
+6
-3
authhook/auth_on_register.js
+2
-1
authhook/validator.js
+4
-2
No files found.
authhook/auth_on_register.js
View file @
c911192b
...
@@ -29,7 +29,7 @@ function authCheck(client_id, token, password, callback) {
...
@@ -29,7 +29,7 @@ function authCheck(client_id, token, password, callback) {
else
{
else
{
console
.
log
(
'token :'
+
token
)
console
.
log
(
'token :'
+
token
)
seneca
.
act
(
'ms:tokenregistry, cmd:getAttributes, type:device, tokencode:'
+
token
,
function
(
err
,
res
)
{
seneca
.
act
(
'ms:tokenregistry, cmd:getAttributes, type:device, tokencode:'
+
token
,
function
(
err
,
res
)
{
//
console.log('result : ' + util.inspect(res.result, false, null, true))
console
.
log
(
'result : '
+
util
.
inspect
(
res
.
result
,
false
,
null
,
true
))
if
(
res
.
result
)
{
if
(
res
.
result
)
{
var
token_profile
=
(
res
&&
res
.
result
&&
res
.
result
[
0
])
?
res
.
result
[
0
]
:
{};
var
token_profile
=
(
res
&&
res
.
result
&&
res
.
result
[
0
])
?
res
.
result
[
0
]
:
{};
var
mqttauth
=
{
var
mqttauth
=
{
...
@@ -37,6 +37,7 @@ function authCheck(client_id, token, password, callback) {
...
@@ -37,6 +37,7 @@ function authCheck(client_id, token, password, callback) {
token
:
token
,
token
:
token
,
password
:
password
password
:
password
};
};
console
.
log
(
util
.
inspect
(
validator
.
auth_connect
(
mqttauth
,
token_profile
),
false
,
null
,
true
))
callback
(
validator
.
auth_connect
(
mqttauth
,
token_profile
).
status
);
callback
(
validator
.
auth_connect
(
mqttauth
,
token_profile
).
status
);
}
}
else
{
else
{
...
...
authhook/validator.js
View file @
c911192b
...
@@ -25,6 +25,8 @@ module.exports.auth_connect = auth_connect
...
@@ -25,6 +25,8 @@ module.exports.auth_connect = auth_connect
}
}
*/
*/
function
auth_connect
(
mqttauth
,
token_profile
)
{
function
auth_connect
(
mqttauth
,
token_profile
)
{
var
dateNow
=
Math
.
floor
(
Date
.
now
()
/
1000
)
var
res
=
{
var
res
=
{
status
:
true
status
:
true
}
}
...
@@ -40,8 +42,8 @@ function auth_connect(mqttauth, token_profile) {
...
@@ -40,8 +42,8 @@ function auth_connect(mqttauth, token_profile) {
}
}
if
(
!
found
)
return
{
status
:
false
,
reason
:
'uneligible'
};
if
(
!
found
)
return
{
status
:
false
,
reason
:
'uneligible'
};
}
}
if
(
Date
.
now
()
>
token_profile
.
exp
)
return
{
status
:
false
,
reason
:
'expired'
};
if
(
dateNow
>
token_profile
.
exp
)
return
{
status
:
false
,
reason
:
'expired'
};
if
(
token_profile
.
nbf
&&
(
Date
.
now
()
<
token_profile
.
nbf
))
return
{
status
:
false
,
reason
:
'uneligible'
};
if
(
token_profile
.
nbf
&&
(
dateNow
<
token_profile
.
nbf
))
return
{
status
:
false
,
reason
:
'uneligible'
};
return
{
status
:
true
};
return
{
status
:
true
};
}
}
...
...
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