Added "restartOnAuthFail" as an option (#112)

- When true, the sessions passed is discarded when reinitialized.
This commit is contained in:
Steven L 2020-03-23 10:52:46 +11:00 • committed by GitHub
commit d08b343815
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -75,7 +75,11 @@ class Client extends EventEmitter {
*/
this.emit(Events.AUTHENTICATION_FAILURE, 'Unable to log in. Are the session details valid?');
browser.close();
if (this.options.restartOnAuthFail) {
// session restore failed so try again but without session to force new authentication
this.options.session = null;
this.initialize(this.options);
}
return;
}