From 4fdc80be01bc21958b83f0dcc5c5efba5d37ce5d Mon Sep 17 00:00:00 2001 From: Jamie Curnow Date: Tue, 21 Mar 2023 17:59:27 +1000 Subject: [PATCH] Fix logical error with keys and mysql config --- backend/lib/config.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/backend/lib/config.js b/backend/lib/config.js index 0df936de..caa57fcf 100644 --- a/backend/lib/config.js +++ b/backend/lib/config.js @@ -20,7 +20,8 @@ const configure = () => { if (configData && configData.database) { logger.info(`Using configuration from file: ${filename}`); - instance = configData; + instance = configData; + instance.keys = getKeys(); return; } } @@ -39,7 +40,8 @@ const configure = () => { user: envMysqlUser, password: process.env.DB_MYSQL_PASSWORD, name: envMysqlName, - } + }, + keys: getKeys(), }; return; } @@ -56,9 +58,12 @@ const configure = () => { }, useNullAsDefault: true } - } + }, + keys: getKeys(), }; +}; +const getKeys = () => { // Get keys from file if (!fs.existsSync(keysFile)) { generateKeys(); @@ -66,13 +71,11 @@ const configure = () => { logger.info('Keys file exists OK'); } try { - instance.keys = require(keysFile); + return require(keysFile); } catch (err) { logger.error('Could not read JWT key pair from config file: ' + keysFile, err); process.exit(1); } - - logger.debug('Configuration: ' + JSON.stringify(instance, null, 2)); }; const generateKeys = () => {