Prompt admin for user log at user creation
This commit is contained in:
parent
b73696a8bf
commit
410eff428b
@ -82,7 +82,7 @@ ClientManager.prototype.getUsers = function() {
|
|||||||
return users;
|
return users;
|
||||||
};
|
};
|
||||||
|
|
||||||
ClientManager.prototype.addUser = function(name, password) {
|
ClientManager.prototype.addUser = function(name, password, enableLog) {
|
||||||
var users = this.getUsers();
|
var users = this.getUsers();
|
||||||
if (users.indexOf(name) !== -1) {
|
if (users.indexOf(name) !== -1) {
|
||||||
return false;
|
return false;
|
||||||
@ -96,7 +96,7 @@ ClientManager.prototype.addUser = function(name, password) {
|
|||||||
var user = {
|
var user = {
|
||||||
user: name,
|
user: name,
|
||||||
password: password || "",
|
password: password || "",
|
||||||
log: false,
|
log: enableLog,
|
||||||
networks: []
|
networks: []
|
||||||
};
|
};
|
||||||
fs.writeFileSync(
|
fs.writeFileSync(
|
||||||
|
@ -24,17 +24,26 @@ program
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!err) {
|
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);
|
var hash = Helper.password.hash(password);
|
||||||
manager.addUser(
|
manager.addUser(name, hash, enableLog);
|
||||||
name,
|
|
||||||
hash
|
|
||||||
);
|
|
||||||
|
|
||||||
log.info(`User ${colors.bold(name)} created.`);
|
log.info(`User ${colors.bold(name)} created.`);
|
||||||
log.info(`User file located at ${colors.green(Helper.getUserConfigPath(name))}.`);
|
log.info(`User file located at ${colors.green(Helper.getUserConfigPath(name))}.`);
|
||||||
|
Loading…
Reference in New Issue
Block a user