Skip to content
This repository was archived by the owner on Feb 4, 2022. It is now read-only.

Commit 864ff9f

Browse files
committed
refactor(topologies): only call callbacks if provided in auth
1 parent dc50d0f commit 864ff9f

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

lib/connection/pool.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -607,15 +607,15 @@ Pool.prototype.connect = function() {
607607
* @param {authResultCallback} callback A callback function
608608
*/
609609
Pool.prototype.auth = function(credentials, callback) {
610-
callback(null, null);
610+
if (typeof callback === 'function') callback(null, null);
611611
};
612612

613613
/**
614614
* Logout all users against a database
615615
* @param {authResultCallback} callback A callback function
616616
*/
617617
Pool.prototype.logout = function(dbName, callback) {
618-
callback(null, null);
618+
if (typeof callback === 'function') callback(null, null);
619619
};
620620

621621
/**

lib/topologies/mongos.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ Mongos.prototype.connect = function(options) {
300300
* @param {authResultCallback} callback A callback function
301301
*/
302302
Mongos.prototype.auth = function(credentials, callback) {
303-
callback(null, null);
303+
if (typeof callback === 'function') callback(null, null);
304304
};
305305

306306
function handleEvent(self) {

lib/topologies/replset.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -940,7 +940,7 @@ ReplSet.prototype.connect = function(options) {
940940
* @param {authResultCallback} callback A callback function
941941
*/
942942
ReplSet.prototype.auth = function(credentials, callback) {
943-
callback(null, null);
943+
if (typeof callback === 'function') callback(null, null);
944944
};
945945

946946
/**

lib/topologies/server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ Server.prototype.connect = function(options) {
505505
* @param {authResultCallback} callback A callback function
506506
*/
507507
Server.prototype.auth = function(credentials, callback) {
508-
callback(null, null);
508+
if (typeof callback === 'function') callback(null, null);
509509
};
510510

511511
/**

0 commit comments

Comments
 (0)