From ea8f819bd5696661f51e9373445fbef182e8bc4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Vest=C3=B8l?= Date: Fri, 8 Jun 2018 13:57:52 +0200 Subject: [PATCH] Fixes for last commit --- master.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/master.js b/master.js index 806ce048..013f5f3a 100644 --- a/master.js +++ b/master.js @@ -22,7 +22,7 @@ debug = false; // constants const masterModFolder = "./database/masterMods/"; -var config = require('./config'); +const config = require('./config'); // homebrew modules const getFactorioLocale = require("./lib/getFactorioLocale"); @@ -56,6 +56,11 @@ function randomStringAsBase64Url(size) { if (!fs.existsSync("secret-api-token.txt")) { config.masterAuthSecret = randomStringAsBase64Url(256); fs.writeFileSync("config.json",JSON.stringify(config, null, 4)); + fs.writeFileSync("secret-api-token.txt", jwt.sign({ id: "api" }, config.masterAuthSecret, { + expiresIn: 86400*365 // expires in 1 year + })); + console.log("Generated new master authentication private key!"); + process.exit(0); } // write an auth token to file fs.writeFileSync("secret-api-token.txt", jwt.sign({ id: "api" }, config.masterAuthSecret, {