diff --git a/packages/bolt-connection/src/connection-provider/authentication-provider.js b/packages/bolt-connection/src/connection-provider/authentication-provider.js index f3bc87491..45888c605 100644 --- a/packages/bolt-connection/src/connection-provider/authentication-provider.js +++ b/packages/bolt-connection/src/connection-provider/authentication-provider.js @@ -30,11 +30,11 @@ export default class AuthenticationProvider { async authenticate ({ connection, auth, skipReAuth, waitReAuth, forceReAuth }) { if (auth != null) { - const shouldReAuth = connection.supportsReAuth === true && ( + const shouldReAuth = connection.authToken == null || (connection.supportsReAuth === true && ( (!object.equals(connection.authToken, auth) && skipReAuth !== true) || forceReAuth === true - ) - if (connection.authToken == null || shouldReAuth) { + )) + if (shouldReAuth) { return await connection.connect(this._userAgent, this._boltAgent, auth, waitReAuth || false) } return connection @@ -42,7 +42,7 @@ export default class AuthenticationProvider { const authToken = await this._authTokenManager.getToken() - if (!object.equals(authToken, connection.authToken)) { + if (connection.authToken == null || !object.equals(authToken, connection.authToken)) { return await connection.connect(this._userAgent, this._boltAgent, authToken, false) } diff --git a/packages/neo4j-driver-deno/lib/bolt-connection/connection-provider/authentication-provider.js b/packages/neo4j-driver-deno/lib/bolt-connection/connection-provider/authentication-provider.js index 8f6c8a452..0dc490cf4 100644 --- a/packages/neo4j-driver-deno/lib/bolt-connection/connection-provider/authentication-provider.js +++ b/packages/neo4j-driver-deno/lib/bolt-connection/connection-provider/authentication-provider.js @@ -30,11 +30,11 @@ export default class AuthenticationProvider { async authenticate ({ connection, auth, skipReAuth, waitReAuth, forceReAuth }) { if (auth != null) { - const shouldReAuth = connection.supportsReAuth === true && ( + const shouldReAuth = connection.authToken == null || (connection.supportsReAuth === true && ( (!object.equals(connection.authToken, auth) && skipReAuth !== true) || forceReAuth === true - ) - if (connection.authToken == null || shouldReAuth) { + )) + if (shouldReAuth) { return await connection.connect(this._userAgent, this._boltAgent, auth, waitReAuth || false) } return connection @@ -42,7 +42,7 @@ export default class AuthenticationProvider { const authToken = await this._authTokenManager.getToken() - if (!object.equals(authToken, connection.authToken)) { + if (connection.authToken == null || !object.equals(authToken, connection.authToken)) { return await connection.connect(this._userAgent, this._boltAgent, authToken, false) }