From 2a852fe13e5e8b149431e56245557f6137e4330d Mon Sep 17 00:00:00 2001 From: MinusGix Date: Sun, 30 Sep 2018 13:41:18 -0500 Subject: Made Admin password saved as a trip. --- server/src/managers/config.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/server/src/managers/config.js b/server/src/managers/config.js index 7929641..26d4ba2 100644 --- a/server/src/managers/config.js +++ b/server/src/managers/config.js @@ -16,6 +16,15 @@ const prompt = require('prompt'); const path = require('path'); const deSync = require('deasync'); +// For hashing the admin's password into a trip. +const crypto = require('crypto'); + +const hash = (password) => { + let sha = crypto.createHash('sha256'); + sha.update(password); + return sha.digest('base64').substr(0, 6); +}; + class ConfigManager { /** * Create a `ConfigManager` instance for (re)loading classes and config @@ -65,6 +74,7 @@ class ConfigManager { default: currentConfig.adminPass, hidden: true, replace: '*', + before: value => hash(value) }, websocketPort: { type: 'number', @@ -98,7 +108,7 @@ class ConfigManager { let conf = {}; conf = this.load(); - // trip salt is the last core config question, wait until it's been populated + // websocketport is the last core config question, wait until it's been populated // TODO: update this to work with new plugin support while(conf === null || typeof conf.websocketPort === 'undefined') { deSync.sleep(100); -- cgit v1.2.1