Commit f1ffcccf by zCaesar

can check different token

parent 74b7fd7f
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)
}
}) })
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment