mirror of
https://github.com/hack-chat/main.git
synced 2024-03-22 13:20:33 +08:00
Made admin pass stored as trip and handled by trip. Admin can now be an admin as long as they use the same password
This commit is contained in:
parent
2a852fe13e
commit
e7724e24fd
@ -32,13 +32,12 @@ exports.parseNickname = (core, data) => {
|
||||
}
|
||||
|
||||
let password = nickArray[1];
|
||||
if (userInfo.nick.toLowerCase() == core.config.adminName.toLowerCase()) {
|
||||
if (password !== core.config.adminPass) {
|
||||
return 'You are not the admin, liar!';
|
||||
} else {
|
||||
userInfo.uType = 'admin';
|
||||
userInfo.trip = 'Admin';
|
||||
}
|
||||
|
||||
if (hash(password + core.config.tripSalt) === core.config.adminTrip) {
|
||||
userInfo.uType = 'admin';
|
||||
userInfo.trip = 'Admin';
|
||||
} else if (userInfo.nick.toLowerCase() == core.config.adminName.toLowerCase()) { // they've got the main-admin name while not being an admin
|
||||
return 'You are not the admin, liar!';
|
||||
} else if (password) {
|
||||
userInfo.trip = hash(password + core.config.tripSalt);
|
||||
}
|
||||
|
@ -50,6 +50,8 @@ class ConfigManager {
|
||||
* @param {Object} optionalConfigs optional (non-core) module config
|
||||
*/
|
||||
getQuestions (currentConfig, optionalConfigs) {
|
||||
let salt = null; // this is so it can be accessed from adminTrip.
|
||||
|
||||
// core server setup questions
|
||||
const questions = {
|
||||
properties: {
|
||||
@ -59,6 +61,10 @@ class ConfigManager {
|
||||
default: currentConfig.tripSalt,
|
||||
hidden: true,
|
||||
replace: '*',
|
||||
before: value => {
|
||||
salt = value;
|
||||
return salt;
|
||||
}
|
||||
},
|
||||
adminName: {
|
||||
pattern: /^"?[a-zA-Z0-9_]+"?$/,
|
||||
@ -68,13 +74,14 @@ class ConfigManager {
|
||||
default: currentConfig.adminName,
|
||||
before: value => value.replace(/"/g, '')
|
||||
},
|
||||
adminPass: {
|
||||
adminTrip: {
|
||||
type: 'string',
|
||||
required: !currentConfig.adminPass,
|
||||
default: currentConfig.adminPass,
|
||||
required: !currentConfig.adminTrip,
|
||||
default: currentConfig.adminTrip,
|
||||
hidden: true,
|
||||
replace: '*',
|
||||
before: value => hash(value)
|
||||
description: 'adminPass',
|
||||
before: value => hash(value + salt)
|
||||
},
|
||||
websocketPort: {
|
||||
type: 'number',
|
||||
|
Loading…
x
Reference in New Issue
Block a user