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:
parent
794c9e16fc
commit
72441beb37
1 changed files with 6 additions and 8 deletions
14
example.js
14
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 => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue