From aa498564466f9b5547d7772493b71f77d658cf4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Astori?= Date: Wed, 23 Aug 2017 01:15:01 -0400 Subject: [PATCH] Warn when adding or listing users in public mode --- src/command-line/add.js | 10 ++++++++-- src/command-line/list.js | 5 +++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/command-line/add.js b/src/command-line/add.js index 184292c3..198e6f4c 100644 --- a/src/command-line/add.js +++ b/src/command-line/add.js @@ -11,12 +11,18 @@ program .description("Add a new user") .on("--help", Utils.extraHelp) .action(function(name) { - var manager = new ClientManager(); - var users = manager.getUsers(); + if (Helper.config.public) { + log.warn(`Users have no effect in ${colors.bold("public")} mode.`); + } + + const manager = new ClientManager(); + const users = manager.getUsers(); + if (users.indexOf(name) !== -1) { log.error(`User ${colors.bold(name)} already exists.`); return; } + log.prompt({ text: "Enter password:", silent: true diff --git a/src/command-line/list.js b/src/command-line/list.js index 4ef58ed6..df447c94 100644 --- a/src/command-line/list.js +++ b/src/command-line/list.js @@ -3,6 +3,7 @@ var ClientManager = new require("../clientManager"); var program = require("commander"); var colors = require("colors/safe"); +const Helper = require("../helper"); const Utils = require("./utils"); program @@ -10,6 +11,10 @@ program .description("List all users") .on("--help", Utils.extraHelp) .action(function() { + if (Helper.config.public) { + log.warn(`Users have no effect in ${colors.bold("public")} mode.`); + } + var users = new ClientManager().getUsers(); if (!users.length) { log.info(`There are currently no users. Create one with ${colors.bold("lounge add ")}.`);