From 72441beb373d4a1f89b45d93f555f637be77c032 Mon Sep 17 00:00:00 2001 From: Gabriel Date: Fri, 28 Feb 2020 18:02:10 -0300 Subject: [PATCH] feat(example): better sesion data save (#79) For more consistency whenever I have a successful authentication I write to the json file the session data --- example.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/example.js b/example.js index aecc146..e42d343 100644 --- a/example.js +++ b/example.js @@ -20,14 +20,12 @@ client.on('qr', (qr) => { client.on('authenticated', (session) => { console.log('AUTHENTICATED', session); - - if (!fs.existsSync(SESSION_FILE_PATH)) { - fs.writeFile(SESSION_FILE_PATH, JSON.stringify(session), function (err) { - if (err) { - console.error(err); - } - }); - } + sessionCfg=session; + fs.writeFile(SESSION_FILE_PATH, JSON.stringify(session), function (err) { + if (err) { + console.error(err); + } + }); }); client.on('auth_failure', msg => {