From 410eff428b3adffdb4152509995ad6252a92fdae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Astori?= Date: Sun, 29 Jan 2017 14:33:57 -0500 Subject: [PATCH] Prompt admin for user log at user creation --- src/clientManager.js | 4 ++-- src/command-line/add.js | 21 +++++++++++++++------ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/clientManager.js b/src/clientManager.js index fd5aefd0..fc681cd9 100644 --- a/src/clientManager.js +++ b/src/clientManager.js @@ -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( diff --git a/src/command-line/add.js b/src/command-line/add.js index 613a02bd..7c0214c5 100644 --- a/src/command-line/add.js +++ b/src/command-line/add.js @@ -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))}.`);