ldap-authentication 3.3.2 → 3.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +8 -8
  2. package/package.json +1 -2
package/index.js CHANGED
@@ -173,10 +173,10 @@ async function authenticateWithAdmin(
173
173
  ldapOpts
174
174
  )
175
175
  } catch (error) {
176
- if (ldapAdminClient.isConnected) {
176
+ if (ldapAdminClient && ldapAdminClient.isConnected) {
177
177
  await ldapAdminClient.unbind()
178
178
  }
179
- throw { admin: error }
179
+ throw new LdapAuthenticationError(error)
180
180
  }
181
181
  let user = await _searchUser(
182
182
  ldapAdminClient,
@@ -200,10 +200,10 @@ async function authenticateWithAdmin(
200
200
  try {
201
201
  ldapUserClient = await _ldapBind(userDn, userPassword, starttls, ldapOpts)
202
202
  } catch (error) {
203
- if (ldapUserClient.isConnected) {
203
+ if (ldapUserClient && ldapUserClient.isConnected) {
204
204
  await ldapUserClient.unbind()
205
205
  }
206
- throw error
206
+ throw new LdapAuthenticationError(error)
207
207
  }
208
208
  if (groupsSearchBase && groupClass && groupMemberAttribute) {
209
209
  let groups = await _searchUserGroups(
@@ -239,10 +239,10 @@ async function authenticateWithUser(
239
239
  try {
240
240
  ldapUserClient = await _ldapBind(userDn, userPassword, starttls, ldapOpts)
241
241
  } catch (error) {
242
- if (ldapUserClient.isConnected) {
242
+ if (ldapUserClient && ldapUserClient.isConnected) {
243
243
  await ldapUserClient.unbind()
244
244
  }
245
- throw error
245
+ throw new LdapAuthenticationError(error)
246
246
  }
247
247
  if (!usernameAttribute || !userSearchBase) {
248
248
  // if usernameAttribute is not provided, no user detail is needed.
@@ -304,10 +304,10 @@ async function verifyUserExists(
304
304
  ldapOpts
305
305
  )
306
306
  } catch (error) {
307
- if (ldapAdminClient.isConnected) {
307
+ if (ldapAdminClient && ldapAdminClient.isConnected) {
308
308
  await ldapAdminClient.unbind()
309
309
  }
310
- throw { admin: error }
310
+ throw new LdapAuthenticationError(error)
311
311
  }
312
312
  let user = await _searchUser(
313
313
  ldapAdminClient,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ldap-authentication",
3
- "version": "3.3.2",
3
+ "version": "3.3.3",
4
4
  "description": "A simple async nodejs library for LDAP user authentication",
5
5
  "main": "index.js",
6
6
  "types": "./index.d.ts",
@@ -15,7 +15,6 @@
15
15
  "ldap",
16
16
  "authenticate",
17
17
  "authentication",
18
- "ldapjs",
19
18
  "ldapts",
20
19
  "security",
21
20
  "simple",