popup info ; token update
This commit is contained in:
@@ -95,8 +95,6 @@ var uploadSkill = function(skill){
|
||||
|
||||
module.exports = {
|
||||
updateSkill: function(skill, db){
|
||||
console.log("update skill function");
|
||||
|
||||
return new Promise((resolve,reject)=>{
|
||||
if (new Date() / 1000 > config.TOKEN_EXPIRES_IN){
|
||||
refreshToken(db).then(()=>{
|
||||
|
||||
@@ -10,12 +10,18 @@ module.exports = {
|
||||
|
||||
loadTokens : function(){
|
||||
db.collection('token_list').findOne().then(tokens=>{
|
||||
config.TOKEN = tokens.access_token;
|
||||
config.REFRESH_TOKEN = tokens.refresh_token;
|
||||
config.TOKEN_EXPIRES_IN = tokens.expires_in;
|
||||
console.log("Tokens loaded");
|
||||
if (tokens !== null){
|
||||
config.TOKEN = tokens.access_token;
|
||||
config.REFRESH_TOKEN = tokens.refresh_token;
|
||||
config.TOKEN_EXPIRES_IN = tokens.expires_in;
|
||||
}else{
|
||||
//Cannot continue without tokens
|
||||
console.log("Cannot continue without tokens in database");
|
||||
process.exit(-1);
|
||||
}
|
||||
}).catch(e=>{
|
||||
console.log("Error loading tokens");
|
||||
console.log("Error loading tokens ! Cannot continue without tokens in database");
|
||||
process.exit(-1);
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user