Commit 8a23e950 by Chavee Issariyapat

fix error

parent edd44052
......@@ -9,10 +9,9 @@ var LRU = require("lru-cache"),
});
var debug = false;
// var authclient = require('seneca')({log: 'silent'})
// .client({port: config.get('authserv_port'), host: config.get('authserv_host')});
var authclient = require('seneca')({log: 'silent'})
.client({port: config.get('authserv_port'), host: config.get('authserv_host')});
// for testing
function authCheck(client_id, token, password, callback) {
verify(token, (err, decoded) => {
......@@ -22,32 +21,30 @@ function authCheck(client_id, token, password, callback) {
* decode.exp
*/
if (err) {
callback(false)
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);
}
});
}
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)
}
})
......
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