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
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
26 deletions
+32
-26
authhook/auth_on_register.js
+32
-26
No files found.
authhook/auth_on_register.js
View file @
f1ffcccf
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
var
LRU
=
require
(
"lru-cache"
),
...
...
@@ -15,41 +16,46 @@ var debug = false;
// for testing
function
authCheck
(
client_id
,
token
,
password
,
callback
)
{
verify
(
token
,
(
err
,
decoded
)
=>
{
checkRealDB
(
token
,
(
err
,
decoded
)
=>
{
/*
* decode.scope
* decode.iat
* decode.exp
*/
if
(
err
)
{
callback
(
false
)
getRole
(
token
,
(
role
)
=>
{
if
(
role
===
false
)
{
callback
(
false
)
}
else
callback
(
true
)
})
}
else
{
// authclient.act({role:'auth',cmd:'token',action:'info',token: token}, function(err, res) {
// if (debug) {
// console.log("res ------>\n");
// console.log(res);
// }
// if (res && res.data) {
// try {
// var jdata = JSON.parse(res.data);
// if (jdata && jdata.code == 200) {
// callback(true);
// }
// else callback(false);
// } catch (e) {
// callback(false);
// }
// callback(true);
// }
// else {
// callback(false);
// }
// });
callback
(
true
)
}
// authclient.act({role:'auth',cmd:'token',action:'info',token: token}, function(err, res) {
// if (debug) {
// console.log("res ------>\n");
// console.log(res);
// }
// if (res && res.data) {
// try {
// var jdata = JSON.parse(res.data);
// if (jdata && jdata.code == 200) {
// callback(true);
// }
// else callback(false);
// } catch (e) {
// callback(false);
// }
// callback(true);
// }
// else {
// callback(false);
// }
// });
})
}
...
...
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