Inform when no users during autoload to take into account removing the last user
This commit is contained in:
parent
90842267e8
commit
f221121998
@ -18,7 +18,7 @@ ClientManager.prototype.init = function(identHandler, sockets) {
|
||||
this.identHandler = identHandler;
|
||||
this.webPush = new WebPush();
|
||||
|
||||
if (!Helper.config.public) {
|
||||
if (!Helper.config.public && !Helper.config.ldap.enable) {
|
||||
if ("autoload" in Helper.config) {
|
||||
log.warn(`Autoloading users is now always enabled. Please remove the ${colors.yellow("autoload")} option from your configuration file.`);
|
||||
}
|
||||
@ -32,12 +32,23 @@ ClientManager.prototype.findClient = function(name) {
|
||||
};
|
||||
|
||||
ClientManager.prototype.autoloadUsers = function() {
|
||||
this.getUsers().forEach((name) => this.loadUser(name));
|
||||
const users = this.getUsers();
|
||||
const noUsersWarning = `There are currently no users. Create one with ${colors.bold("lounge add <name>")}.`;
|
||||
|
||||
if (!users.length) {
|
||||
log.info(noUsersWarning);
|
||||
}
|
||||
|
||||
users.forEach((name) => this.loadUser(name));
|
||||
|
||||
fs.watch(Helper.USERS_PATH, _.debounce(() => {
|
||||
const loaded = this.clients.map((c) => c.name);
|
||||
const updatedUsers = this.getUsers();
|
||||
|
||||
if (!updatedUsers.length) {
|
||||
log.info(noUsersWarning);
|
||||
}
|
||||
|
||||
// New users created since last time users were loaded
|
||||
_.difference(updatedUsers, loaded).forEach((name) => this.loadUser(name));
|
||||
|
||||
|
@ -12,7 +12,7 @@ program
|
||||
.action(function() {
|
||||
var users = new ClientManager().getUsers();
|
||||
if (!users.length) {
|
||||
log.warn("No users found.");
|
||||
log.info(`There are currently no users. Create one with ${colors.bold("lounge add <name>")}.`);
|
||||
} else {
|
||||
log.info("Users:");
|
||||
for (var i = 0; i < users.length; i++) {
|
||||
|
@ -1,8 +1,6 @@
|
||||
"use strict";
|
||||
|
||||
var ClientManager = new require("../clientManager");
|
||||
var program = require("commander");
|
||||
var colors = require("colors/safe");
|
||||
var server = require("../server");
|
||||
var Helper = require("../helper");
|
||||
const Utils = require("./utils");
|
||||
@ -17,8 +15,6 @@ program
|
||||
.description("Start the server")
|
||||
.on("--help", Utils.extraHelp)
|
||||
.action(function(options) {
|
||||
var users = new ClientManager().getUsers();
|
||||
|
||||
var mode = Helper.config.public;
|
||||
if (options.public) {
|
||||
mode = true;
|
||||
@ -26,11 +22,6 @@ program
|
||||
mode = false;
|
||||
}
|
||||
|
||||
if (!mode && !users.length && !Helper.config.ldap.enable) {
|
||||
log.warn("No users found.");
|
||||
log.info(`Create a new user with ${colors.bold("lounge add <name>")}.`);
|
||||
}
|
||||
|
||||
Helper.config.host = options.host || Helper.config.host;
|
||||
Helper.config.port = options.port || Helper.config.port;
|
||||
Helper.config.bind = options.bind || Helper.config.bind;
|
||||
|
Loading…
Reference in New Issue
Block a user