diff --git a/README.md b/README.md index a38e56d..6c1bfba 100644 --- a/README.md +++ b/README.md @@ -346,10 +346,10 @@ This section provides integration guides for configuring the UniFi Voucher Site Below is a list of tested Identity Providers (IdPs) with detailed integration instructions: -- [Keycloak Integration](.docs/oidc/keycloak/README.md) -- [Authentik Integration](.docs/oidc/authentik/README.md) +- [Keycloak](.docs/oidc/keycloak/README.md) +- [Authentik](.docs/oidc/authentik/README.md) - [UniFi Identity Enterprise (UID)](.docs/oidc/uid/README.md) -- [ZITADEL Integration](.docs/oidc/zitadel/README.md) +- [ZITADEL](.docs/oidc/zitadel/README.md) > Integrated with an IdP that is not on the list? Feel free to create a guide for others and contribute it to the project diff --git a/modules/config.js b/modules/config.js index 7adf02e..bd8aeb9 100644 --- a/modules/config.js +++ b/modules/config.js @@ -7,16 +7,19 @@ const fs = require('fs'); * Get an option from external config (Home Assistant / Local Development) * * @param option + * @return {*|null} */ module.exports = (option) => { // Check if Home Assistant config exists if (fs.existsSync('/data/options.json')) { - return JSON.parse(fs.readFileSync('/data/options.json', 'utf-8'))[option]; + const data = JSON.parse(fs.readFileSync('/data/options.json', 'utf-8')); + return typeof data[option] !== 'undefined' ? data[option] : null; } // Check if Local (Development) config exists if (fs.existsSync(`${__dirname}/../.options.json`)) { - return JSON.parse(fs.readFileSync(`${__dirname}/../.options.json`, 'utf-8'))[option]; + const data = JSON.parse(fs.readFileSync(`${__dirname}/../.options.json`, 'utf-8')); + return typeof data[option] !== 'undefined' ? data[option] : null; } return null; diff --git a/modules/variables.js b/modules/variables.js index 83bf94c..384d31b 100644 --- a/modules/variables.js +++ b/modules/variables.js @@ -15,10 +15,10 @@ module.exports = { unifiSsid: config('unifi_ssid') || process.env.UNIFI_SSID || '', unifiSsidPassword: config('unifi_ssid_password') || process.env.UNIFI_SSID_PASSWORD || '', voucherTypes: config('voucher_types') || process.env.VOUCHER_TYPES || '480,1,,,;', - voucherCustom: typeof config('voucher_custom') !== 'undefined' ? config('voucher_custom') : typeof process.env.VOUCHER_CUSTOM !== 'undefined' ? process.env.VOUCHER_CUSTOM !== 'false' : true, - serviceWeb: typeof config('service_web') !== 'undefined' ? config('service_web') : typeof process.env.SERVICE_WEB !== 'undefined' ? process.env.SERVICE_WEB !== 'false' : true, + voucherCustom: config('voucher_custom') !== null ? config('voucher_custom') : process.env.VOUCHER_CUSTOM ? process.env.VOUCHER_CUSTOM !== 'false' : true, + serviceWeb: config('service_web') !== null ? config('service_web') : process.env.SERVICE_WEB ? process.env.SERVICE_WEB !== 'false' : true, serviceApi: config('service_api') || (process.env.SERVICE_API === 'true') || false, - authInternalEnabled: typeof config('auth_internal_enabled') !== 'undefined' ? config('auth_internal_enabled') : typeof process.env.AUTH_INTERNAL_ENABLED !== 'undefined' ? process.env.AUTH_INTERNAL_ENABLED !== 'false' : true, + authInternalEnabled: config('auth_internal_enabled') !== null ? config('auth_internal_enabled') : process.env.AUTH_INTERNAL_ENABLED ? process.env.AUTH_INTERNAL_ENABLED !== 'false' : true, authInternalPassword: config('auth_internal_password') || process.env.AUTH_INTERNAL_PASSWORD || '0000', authToken: config('auth_internal_bearer_token') || process.env.AUTH_INTERNAL_BEARER_TOKEN || '00000000-0000-0000-0000-000000000000', authOidcEnabled: config('auth_oidc_enabled') || (process.env.AUTH_OIDC_ENABLED === 'true') || false,