|
@@ -37,6 +37,10 @@ jsonfile.readFile(tokenFile, function (err, obj) {
|
|
|
function updateTokenEnv(data){
|
|
|
|
|
|
let reqObj = data
|
|
|
+ info.token = reqObj
|
|
|
+ info.authorized = true;
|
|
|
+ info.active = true
|
|
|
+
|
|
|
console.log("[updateTokenEnv] :");
|
|
|
console.log(data);
|
|
|
jsonfile.writeFile(tokenFile, reqObj, function (err) {
|
|
@@ -64,9 +68,8 @@ async function watchLinkedin(){
|
|
|
// try refresh token
|
|
|
const data = await API.getAccessToken(info.token)
|
|
|
|
|
|
- if(data.access_token) {
|
|
|
- mail.notif();
|
|
|
- }
|
|
|
+ if(!data.access_token) mail.notif();
|
|
|
+ else
|
|
|
}
|
|
|
});
|
|
|
}
|
|
@@ -94,14 +97,8 @@ app.get('/callback', async (req, res) => {
|
|
|
}
|
|
|
try {
|
|
|
const data = await API.getAccessToken(req.query.code);
|
|
|
- if(data.access_token) {
|
|
|
- info.token = data.access_token;
|
|
|
- info.authorized = true;
|
|
|
- info.active = true
|
|
|
- process.env.access_token = info.token
|
|
|
- process.env.expire = data.expire ? data.expire : 0
|
|
|
- updateTokenEnv(data)
|
|
|
- }
|
|
|
+ if(data.access_token) updateTokenEnv(data)
|
|
|
+
|
|
|
res.redirect('/');
|
|
|
} catch(err) {
|
|
|
res.json(err);
|