aboutsummaryrefslogtreecommitdiffstats
path: root/server/src/managers
diff options
context:
space:
mode:
authorMinusGix <minusgix@gmail.com>2018-09-30 20:41:18 +0200
committerMinusGix <minusgix@gmail.com>2018-09-30 20:41:18 +0200
commit2a852fe13e5e8b149431e56245557f6137e4330d (patch)
tree913d443dc8ba07c8e10c569960e7cd1b51c4630f /server/src/managers
parentPut tripsalt question before password question. (diff)
downloadhackchat-2a852fe13e5e8b149431e56245557f6137e4330d.tar.gz
hackchat-2a852fe13e5e8b149431e56245557f6137e4330d.zip
Made Admin password saved as a trip.
Diffstat (limited to '')
-rw-r--r--server/src/managers/config.js12
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);