From 1b75d0d24360c71907689373a2eb4b61f9fd10b3 Mon Sep 17 00:00:00 2001 From: Pedro Lopez Date: Tue, 1 Mar 2022 22:25:22 -0400 Subject: [PATCH] fix(LocalAuth): only throw user-supplied userDataDir error if path is different fix #1261 --- src/authStrategies/LocalAuth.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/authStrategies/LocalAuth.js b/src/authStrategies/LocalAuth.js index 1f9770d..dcf000a 100644 --- a/src/authStrategies/LocalAuth.js +++ b/src/authStrategies/LocalAuth.js @@ -25,14 +25,13 @@ class LocalAuth extends BaseAuthStrategy { async beforeBrowserInitialized() { const puppeteerOpts = this.client.options.puppeteer; - - if(puppeteerOpts.userDataDir) { - throw new Error('LocalAuth is not compatible with a user-supplied userDataDir.'); - } - const sessionDirName = this.clientId ? `session-${this.clientId}` : 'session'; const dirPath = path.join(this.dataPath, sessionDirName); + if(puppeteerOpts.userDataDir && puppeteerOpts.userDataDir !== dirPath) { + throw new Error('LocalAuth is not compatible with a user-supplied userDataDir.'); + } + fs.mkdirSync(dirPath, { recursive: true }); this.client.options.puppeteer = {