Skip to content

Commit 4fdc80b

Browse files
committed
Fix logical error with keys and mysql config
1 parent f8e6c8d commit 4fdc80b

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

backend/lib/config.js

+9-6
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ const configure = () => {
2020

2121
if (configData && configData.database) {
2222
logger.info(`Using configuration from file: ${filename}`);
23-
instance = configData;
23+
instance = configData;
24+
instance.keys = getKeys();
2425
return;
2526
}
2627
}
@@ -39,7 +40,8 @@ const configure = () => {
3940
user: envMysqlUser,
4041
password: process.env.DB_MYSQL_PASSWORD,
4142
name: envMysqlName,
42-
}
43+
},
44+
keys: getKeys(),
4345
};
4446
return;
4547
}
@@ -56,23 +58,24 @@ const configure = () => {
5658
},
5759
useNullAsDefault: true
5860
}
59-
}
61+
},
62+
keys: getKeys(),
6063
};
64+
};
6165

66+
const getKeys = () => {
6267
// Get keys from file
6368
if (!fs.existsSync(keysFile)) {
6469
generateKeys();
6570
} else if (process.env.DEBUG) {
6671
logger.info('Keys file exists OK');
6772
}
6873
try {
69-
instance.keys = require(keysFile);
74+
return require(keysFile);
7075
} catch (err) {
7176
logger.error('Could not read JWT key pair from config file: ' + keysFile, err);
7277
process.exit(1);
7378
}
74-
75-
logger.debug('Configuration: ' + JSON.stringify(instance, null, 2));
7679
};
7780

7881
const generateKeys = () => {

0 commit comments

Comments
 (0)