Skip to content

Commit edac1b6

Browse files
committed
Unbind clients when closing
Previously no client was unbound (see trentm#3), now unbinding both without keeping track if they were actually bound as this seems to be working (and also destroy-method in ldapjs' connection pool does so).
1 parent d91714e commit edac1b6

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

lib/ldapauth.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,12 @@ function LdapAuth(opts) {
8989

9090

9191
LdapAuth.prototype.close = function (callback) {
92-
if (! this._adminBound) {
93-
callback()
94-
} else {
95-
this._adminClient.unbind(function (err) {
96-
callback(err);
97-
});
98-
}
92+
var self = this;
93+
// It seems to be OK just to call unbind regardless of if the
94+
// client has been bound (e.g. how ldapjs pool destroy does)
95+
self._adminClient.unbind(function(err) {
96+
self._userClient.unbind(callback);
97+
});
9998
}
10099

101100

@@ -117,6 +116,7 @@ LdapAuth.prototype._adminBind = function (callback) {
117116
self.log && self.log.trace('ldap authenticate: bind error: %s', err);
118117
return callback(err);
119118
}
119+
self._adminBound = true;
120120
return callback();
121121
});
122122
}

0 commit comments

Comments
 (0)