Skip to content

Commit

Permalink
fix: Avoid localStorage override for multidevice
Browse files Browse the repository at this point in the history
  • Loading branch information
edgardmessias committed Oct 18, 2022
1 parent 4f7bd6e commit 7d10159
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/controllers/auth.ts
Expand Up @@ -21,6 +21,7 @@ import * as puppeteer from 'puppeteer';
import * as qrcode from 'qrcode-terminal';
import { puppeteerConfig } from '../config/puppeteer.config';
import { isValidSessionToken } from '../token-store';
import { sleep } from '../utils/sleep';

export const getInterfaceStatus = async (
waPage: puppeteer.Page
Expand Down Expand Up @@ -190,13 +191,21 @@ export async function injectSessionToken(
})
.catch(() => null);
});

await sleep(2000);
}
await page.evaluate((session) => {
Object.keys(session).forEach((key) => {
localStorage.setItem(key, session[key]);
});

if (token.WASecretBundle !== 'MultiDevice') {
await page.evaluate((session) => {
Object.keys(session).forEach((key) => {
localStorage.setItem(key, session[key]);
});
}, token as any);
}

await page.evaluate(() => {
localStorage.setItem('remember-me', 'true');
}, token as any);
});

// Disable
page.removeAllListeners('request');
Expand Down

0 comments on commit 7d10159

Please sign in to comment.