Skip to content

Commit

Permalink
Updated README.md. Revert type check within variables.js. Implemented…
Browse files Browse the repository at this point in the history
… type check within config.js, fallback to 'null' when option is not defined
  • Loading branch information
glenndehaan committed Oct 6, 2024
1 parent 117b18e commit eacb0b4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 5 additions & 2 deletions modules/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions modules/variables.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit eacb0b4

Please sign in to comment.