I got stuck in getting the result return from the function for authentication the user.
utility.isAspAuth = function(token){
queryString = {
sql: 'SELECT * FROM SecurityToken WHERE Token = ?',
timeout: 40000, // 40s
values: [token]
};
var curTime = new Date();
connection.query(queryString,function(err,rows,field){
if(err){
console.log('error on query' + err);
}else{
var result = rows[0];
result.forEach(function(element, index, array){
if(Date.parse(result.Expires) > curTime){
return true;
}else{
return false;
}
});
}
});
};
so I call this function in another file, but the result is undefined
console.log(utility.isAspAuth(token))
can someone give me some hint on how to fix it?
Thank you so much