Warn when adding or listing users in public mode
This commit is contained in:
parent
f221121998
commit
aa49856446
@ -11,12 +11,18 @@ program
|
|||||||
.description("Add a new user")
|
.description("Add a new user")
|
||||||
.on("--help", Utils.extraHelp)
|
.on("--help", Utils.extraHelp)
|
||||||
.action(function(name) {
|
.action(function(name) {
|
||||||
var manager = new ClientManager();
|
if (Helper.config.public) {
|
||||||
var users = manager.getUsers();
|
log.warn(`Users have no effect in ${colors.bold("public")} mode.`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const manager = new ClientManager();
|
||||||
|
const users = manager.getUsers();
|
||||||
|
|
||||||
if (users.indexOf(name) !== -1) {
|
if (users.indexOf(name) !== -1) {
|
||||||
log.error(`User ${colors.bold(name)} already exists.`);
|
log.error(`User ${colors.bold(name)} already exists.`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
log.prompt({
|
log.prompt({
|
||||||
text: "Enter password:",
|
text: "Enter password:",
|
||||||
silent: true
|
silent: true
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
var ClientManager = new require("../clientManager");
|
var ClientManager = new require("../clientManager");
|
||||||
var program = require("commander");
|
var program = require("commander");
|
||||||
var colors = require("colors/safe");
|
var colors = require("colors/safe");
|
||||||
|
const Helper = require("../helper");
|
||||||
const Utils = require("./utils");
|
const Utils = require("./utils");
|
||||||
|
|
||||||
program
|
program
|
||||||
@ -10,6 +11,10 @@ program
|
|||||||
.description("List all users")
|
.description("List all users")
|
||||||
.on("--help", Utils.extraHelp)
|
.on("--help", Utils.extraHelp)
|
||||||
.action(function() {
|
.action(function() {
|
||||||
|
if (Helper.config.public) {
|
||||||
|
log.warn(`Users have no effect in ${colors.bold("public")} mode.`);
|
||||||
|
}
|
||||||
|
|
||||||
var users = new ClientManager().getUsers();
|
var users = new ClientManager().getUsers();
|
||||||
if (!users.length) {
|
if (!users.length) {
|
||||||
log.info(`There are currently no users. Create one with ${colors.bold("lounge add <name>")}.`);
|
log.info(`There are currently no users. Create one with ${colors.bold("lounge add <name>")}.`);
|
||||||
|
Loading…
Reference in New Issue
Block a user