Warn when adding or listing users in public mode

This commit is contained in:
Jérémie Astori 2017-08-23 01:15:01 -04:00
parent f221121998
commit aa49856446
No known key found for this signature in database
GPG Key ID: B9A4F245CD67BDE8
2 changed files with 13 additions and 2 deletions

View File

@ -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

View File

@ -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 <name>")}.`);