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
f1ffcccf
Commit
f1ffcccf
authored
Sep 16, 2018
by
zCaesar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
can check different token
parent
74b7fd7f
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
4 deletions
+10
-4
authhook/auth_on_register.js
+10
-4
No files found.
authhook/auth_on_register.js
View file @
f1ffcccf
var
config
=
require
(
'config'
);
var
config
=
require
(
'config'
);
var
verify
=
require
(
'./verifyToken'
).
verifyToken
var
checkRealDB
=
require
(
'./checkClientRole'
).
checkRealDB
var
getRole
=
require
(
'./checkClientRole'
).
getRole
// https://github.com/isaacs/node-lru-cache
// https://github.com/isaacs/node-lru-cache
var
LRU
=
require
(
"lru-cache"
),
var
LRU
=
require
(
"lru-cache"
),
...
@@ -15,16 +16,23 @@ var debug = false;
...
@@ -15,16 +16,23 @@ var debug = false;
// for testing
// for testing
function
authCheck
(
client_id
,
token
,
password
,
callback
)
{
function
authCheck
(
client_id
,
token
,
password
,
callback
)
{
verify
(
token
,
(
err
,
decoded
)
=>
{
checkRealDB
(
token
,
(
err
,
decoded
)
=>
{
/*
/*
* decode.scope
* decode.scope
* decode.iat
* decode.iat
* decode.exp
* decode.exp
*/
*/
if
(
err
)
{
if
(
err
)
{
getRole
(
token
,
(
role
)
=>
{
if
(
role
===
false
)
{
callback
(
false
)
callback
(
false
)
}
}
else
callback
(
true
)
})
}
else
{
else
{
callback
(
true
)
}
// authclient.act({role:'auth',cmd:'token',action:'info',token: token}, function(err, res) {
// authclient.act({role:'auth',cmd:'token',action:'info',token: token}, function(err, res) {
// if (debug) {
// if (debug) {
...
@@ -48,8 +56,6 @@ function authCheck(client_id, token, password, callback) {
...
@@ -48,8 +56,6 @@ function authCheck(client_id, token, password, callback) {
// callback(false);
// callback(false);
// }
// }
// });
// });
callback
(
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