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
This commit is contained in:
Gabriel 2020-02-28 18:02:10 -03:00 • committed by GitHub
commit 72441beb37
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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 => {