diff options
author | MinusGix <minusgix@gmail.com> | 2018-09-30 20:41:18 +0200 |
---|---|---|
committer | MinusGix <minusgix@gmail.com> | 2018-09-30 20:41:18 +0200 |
commit | 2a852fe13e5e8b149431e56245557f6137e4330d (patch) | |
tree | 913d443dc8ba07c8e10c569960e7cd1b51c4630f | |
parent | Put tripsalt question before password question. (diff) | |
download | hackchat-2a852fe13e5e8b149431e56245557f6137e4330d.tar.gz hackchat-2a852fe13e5e8b149431e56245557f6137e4330d.zip |
Made Admin password saved as a trip.
-rw-r--r-- | server/src/managers/config.js | 12 |
1 files changed, 11 insertions, 1 deletions
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); |