Prompt admin for user log at user creation

This commit is contained in:
Jérémie Astori 2017-01-29 14:33:57 -05:00
parent b73696a8bf
commit 410eff428b
2 changed files with 17 additions and 8 deletions

View File

@ -82,7 +82,7 @@ ClientManager.prototype.getUsers = function() {
return users;
};
ClientManager.prototype.addUser = function(name, password) {
ClientManager.prototype.addUser = function(name, password, enableLog) {
var users = this.getUsers();
if (users.indexOf(name) !== -1) {
return false;
@ -96,7 +96,7 @@ ClientManager.prototype.addUser = function(name, password) {
var user = {
user: name,
password: password || "",
log: false,
log: enableLog,
networks: []
};
fs.writeFileSync(

View File

@ -24,17 +24,26 @@ program
return;
}
if (!err) {
add(manager, name, password);
log.prompt({
text: "Save logs to disk?",
default: "yes"
}, function(err2, enableLog) {
if (!err2) {
add(
manager,
name,
password,
enableLog.charAt(0).toLowerCase() === "y"
);
}
});
}
});
});
function add(manager, name, password) {
function add(manager, name, password, enableLog) {
var hash = Helper.password.hash(password);
manager.addUser(
name,
hash
);
manager.addUser(name, hash, enableLog);
log.info(`User ${colors.bold(name)} created.`);
log.info(`User file located at ${colors.green(Helper.getUserConfigPath(name))}.`);