milux / ctldap

LDAP Wrapper for ChurchTools
GNU General Public License v3.0
12 stars 8 forks source link

Error with new 3.0.0 release #39

Closed a-schild closed 1 year ago

a-schild commented 1 year ago

Got the new version up and running, but upon issuing the test request with my login it throws this error

ldap_1  | 2023-02-18T14:53:45.076Z [DEBUG] root logger - Debug mode enabled, expect lots of output!
ldap_1  | 2023-02-18T14:53:45.088Z [DEBUG] root logger - ChurchTools-LDAP-Wrapper listening @ ldap://0.0.0.0:1389
ldap_1  | 2023-02-18T14:53:50.428Z [DEBUG] churchtools - Admin bind DN: cn=root, ou=users, o=churchtools
ldap_1  | 2023-02-18T14:53:50.428Z [DEBUG] churchtools - Admin bind successful
ldap_1  | 2023-02-18T14:53:50.436Z [DEBUG] churchtools - SEARCH base object: o=churchtools scope: sub
ldap_1  | 2023-02-18T14:53:50.437Z [DEBUG] churchtools - Filter: (&(&(objectclass=ctperson))(|(cn=*andre*)(mail=*andre*)))
ldap_1  | 2023-02-18T14:53:50.438Z [DEBUG] churchtools - Search for users and groups combined
ldap_1  | 2023-02-18T14:53:50.445Z [DEBUG] churchtools - Wait on Promise for cache key "rawData".
ldap_1  | 2023-02-18T14:53:50.445Z [DEBUG] churchtools - Wait on Promise for cache key "users".
ldap_1  | 2023-02-18T14:53:50.446Z [DEBUG] churchtools - Returning pending Promise for cache key "rawData".
ldap_1  | 2023-02-18T14:53:50.446Z [DEBUG] churchtools - Wait on Promise for cache key "rawData".
ldap_1  | 2023-02-18T14:53:50.447Z [DEBUG] churchtools - Wait on Promise for cache key "groups".
ldap_1  | 2023-02-18T14:53:50.775Z [DEBUG] churchtools - fetchGroupTypes done
ldap_1  | 2023-02-18T14:53:50.963Z [DEBUG] churchtools - fetchMemberships done
ldap_1  | 2023-02-18T14:53:51.221Z [DEBUG] churchtools - fetchGroups done
ldap_1  | 2023-02-18T14:53:51.540Z [DEBUG] churchtools - Admin bind DN: cn=root, ou=users, o=churchtools
ldap_1  | 2023-02-18T14:53:51.540Z [DEBUG] churchtools - Admin bind successful
ldap_1  | 2023-02-18T14:53:51.543Z [DEBUG] churchtools - SEARCH base object: cn=cvon wartburg, ou=users, o=churchtools scope: base
ldap_1  | 2023-02-18T14:53:51.543Z [DEBUG] churchtools - Filter: (objectclass=*)
ldap_1  | 2023-02-18T14:53:51.544Z [DEBUG] churchtools - Search for users
ldap_1  | 2023-02-18T14:53:51.544Z [DEBUG] churchtools - Returning pending Promise for cache key "users".
ldap_1  | 2023-02-18T14:53:51.544Z [DEBUG] churchtools - Wait on Promise for cache key "users".
ldap_1  | 2023-02-18T14:53:52.377Z [DEBUG] churchtools - fetchPersons done
ldap_1  | 2023-02-18T14:53:52.380Z [DEBUG] churchtools - Store cache entry for cache key "rawData".
ldap_1  | 2023-02-18T14:53:52.382Z [DEBUG] churchtools - Updated users: 61
ldap_1  | 2023-02-18T14:53:52.383Z [DEBUG] churchtools - Updated groups: 178
ldap_1  | 2023-02-18T14:53:52.384Z [DEBUG] churchtools - Store cache entry for cache key "users".
ldap_1  | 2023-02-18T14:53:52.384Z [DEBUG] churchtools - Store cache entry for cache key "groups".
ldap_1  | 2023-02-18T14:53:52.387Z [DEBUG] churchtools - MatchUser: cn=cvon wartburg,ou=users,o=churchtools
ldap_1  | file:///app/ctldap.js:637
ldap_1  |   const tv = helpers.getAttrValue(target, this.attribute, strictAttrCase);
ldap_1  |                                                ^
ldap_1  |
ldap_1  | TypeError: Cannot read properties of undefined (reading 'attribute')
ldap_1  |     at ldap.filters.SubstringFilter.matches (file:///app/ctldap.js:637:48)
ldap_1  |     at OrFilter.matches (/app/node_modules/ldapjs/node_modules/ldap-filter/lib/or_filter.js:49:25)
ldap_1  |     at AndFilter.matches (/app/node_modules/ldapjs/node_modules/ldap-filter/lib/and_filter.js:54:26)
ldap_1  |     at file:///app/ctldap.js:481:81
ldap_1  |     at Array.forEach (<anonymous>)
ldap_1  |     at file:///app/ctldap.js:480:11
ldap_1  |     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
ldap_1  |
ldap_1  | Node.js v18.14.1
milux commented 1 year ago

This is seemingly related to changes I made analogous to https://github.com/churchtools/ctldap-ms/pull/4. Interesting... Could you console.log() the attributes and the this context when this error is thrown?

milux commented 1 year ago

Ah, found the reason! I was a bit stupid. :laughing: Arrow functions make it impossible to override the this context, so now its always the parent object of ctldap.js. :facepalm: Fix to follow soon.

milux commented 1 year ago

Should be fixed with 3.0.1 now.