Add auto reauth when failure

This commit is contained in:
Nur Muhammad
2020-11-09 14:31:48 +08:00
parent 28f704ac52
commit 0cf25de312
2 changed files with 6 additions and 0 deletions

5
app.js
View File

@@ -34,6 +34,7 @@ app.get('/', (req, res) => {
}); });
const client = new Client({ const client = new Client({
restartOnAuthFail: true,
puppeteer: { puppeteer: {
headless: true, headless: true,
args: [ args: [
@@ -110,6 +111,10 @@ io.on('connection', function(socket) {
client.on('disconnected', (reason) => { client.on('disconnected', (reason) => {
socket.emit('message', 'Whatsapp is disconnected!'); socket.emit('message', 'Whatsapp is disconnected!');
fs.unlinkSync(SESSION_FILE_PATH, function(err) {
if(err) return console.log(err);
console.log('Session file deleted!');
});
client.destroy(); client.destroy();
client.initialize(); client.initialize();
}); });

View File

@@ -25,6 +25,7 @@
socket.on('qr', function(src) { socket.on('qr', function(src) {
$('#qrcode').attr('src', src); $('#qrcode').attr('src', src);
$('#qrcode').show();
}); });
socket.on('ready', function(data) { socket.on('ready', function(data) {