From ad41ff4bb4328de1e3613dfbaab78c38e3a38f8c Mon Sep 17 00:00:00 2001 From: Shane Spoor Date: Sat, 4 May 2019 00:36:09 -0700 Subject: [PATCH] Propagate error on LDAPS SSL cert verification failure --- shell/imports/server/accounts/ldap.js | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/shell/imports/server/accounts/ldap.js b/shell/imports/server/accounts/ldap.js index 2b63bb392f..b69b072652 100644 --- a/shell/imports/server/accounts/ldap.js +++ b/shell/imports/server/accounts/ldap.js @@ -89,8 +89,6 @@ LDAP.prototype.ldapCheck = function (db, options) { }, errorFunc); } - client.on("error", errorFunc); - let username = options.username; let domain = _this.options.defaultDomain; @@ -111,15 +109,16 @@ LDAP.prototype.ldapCheck = function (db, options) { if (_this.options.searchBindDn) { let ldapBindFut = new Future(); - client.bind(_this.options.searchBindDn, _this.options.searchBindPassword, - function (err) { - if (err) { - ldapBindFut.throw(err); - } else { - ldapBindFut.return(); - } + let searchBindErrorFunc = function (err) { + if (err) { + ldapBindFut.throw(err); + } else { + ldapBindFut.return(); } - ); + }; + + client.on("error", searchBindErrorFunc); + client.bind(_this.options.searchBindDn, _this.options.searchBindPassword, searchBindErrorFunc); try { ldapBindFut.wait(); @@ -127,6 +126,8 @@ LDAP.prototype.ldapCheck = function (db, options) { return { error: err }; } } + + client.on("error", errorFunc); // initialize result let retObject = { username: username,