From c40b47135cbab301f3a54afab1d9f6d85c96756a Mon Sep 17 00:00:00 2001 From: David Mehren Date: Mon, 14 Jun 2021 17:23:45 +0200 Subject: [PATCH] Fix parsing the LDAP_CONTACTS environment variable The current code skips loading contact information from LDAP if `!process.env.LDAP_CONTACTS` evaluates to `true`. This is nearly never the case, as `process.env` contains strings and non-empty strings evaluate to `true`, making the negation falsy. Only an empty string in `LDAP_CONTACTS` (or not setting the environment variable at all) skips the contact loading. This commit changes the logic to only load contacts from LDAP if the `LDAP_CONTACTS` environment variable is explicitly set to `"true"` (case insensitive). This should bring the behaviour of the application more in line with the expectation and the docs. --- ldap-overleaf-sl/sharelatex/ContactController.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ldap-overleaf-sl/sharelatex/ContactController.js b/ldap-overleaf-sl/sharelatex/ContactController.js index 2f4f01d..3fb59bc 100644 --- a/ldap-overleaf-sl/sharelatex/ContactController.js +++ b/ldap-overleaf-sl/sharelatex/ContactController.js @@ -80,7 +80,7 @@ module.exports = ContactsController = { }) }, async getLdapContacts(contacts) { - if (! process.env.LDAP_CONTACTS) { + if (process.env.LDAP_CONTACTS === undefined || !(process.env.LDAP_CONTACTS.toLowerCase() === 'true')) { return contacts } const client = new Client({