1
0
mirror of https://github.com/hack-chat/main.git synced 2024-03-22 13:20:33 +08:00

Made Admin password saved as a trip.

This commit is contained in:
MinusGix 2018-09-30 13:41:18 -05:00
parent a7783947a1
commit 2a852fe13e

View File

@ -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);