parent
d8a6b137fe
commit
fe4e0343a4
@ -20,27 +20,34 @@ ClientManager.prototype.init = function(identHandler, sockets) {
|
|||||||
this.identHandler = identHandler;
|
this.identHandler = identHandler;
|
||||||
this.webPush = new WebPush();
|
this.webPush = new WebPush();
|
||||||
|
|
||||||
if (!Helper.config.public && !Helper.config.ldap.enable) {
|
if (!Helper.config.public) {
|
||||||
|
this.loadUsers();
|
||||||
|
|
||||||
|
// LDAP does not have user commands, and users are dynamically
|
||||||
|
// created upon logon, so we don't need to watch for new files
|
||||||
|
if (!Helper.config.ldap.enable) {
|
||||||
this.autoloadUsers();
|
this.autoloadUsers();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ClientManager.prototype.findClient = function(name) {
|
ClientManager.prototype.findClient = function(name) {
|
||||||
return this.clients.find((u) => u.name === name);
|
return this.clients.find((u) => u.name === name);
|
||||||
};
|
};
|
||||||
|
|
||||||
ClientManager.prototype.autoloadUsers = function() {
|
ClientManager.prototype.loadUsers = function() {
|
||||||
const users = this.getUsers();
|
const users = this.getUsers();
|
||||||
const noUsersWarning = `There are currently no users. Create one with ${colors.bold(
|
|
||||||
"thelounge add <name>"
|
|
||||||
)}.`;
|
|
||||||
|
|
||||||
if (users.length === 0) {
|
if (users.length === 0) {
|
||||||
log.info(noUsersWarning);
|
log.info(
|
||||||
|
`There are currently no users. Create one with ${colors.bold("thelounge add <name>")}.`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
users.forEach((name) => this.loadUser(name));
|
users.forEach((name) => this.loadUser(name));
|
||||||
|
};
|
||||||
|
|
||||||
|
ClientManager.prototype.autoloadUsers = function() {
|
||||||
fs.watch(
|
fs.watch(
|
||||||
Helper.getUsersPath(),
|
Helper.getUsersPath(),
|
||||||
_.debounce(
|
_.debounce(
|
||||||
@ -49,7 +56,11 @@ ClientManager.prototype.autoloadUsers = function() {
|
|||||||
const updatedUsers = this.getUsers();
|
const updatedUsers = this.getUsers();
|
||||||
|
|
||||||
if (updatedUsers.length === 0) {
|
if (updatedUsers.length === 0) {
|
||||||
log.info(noUsersWarning);
|
log.info(
|
||||||
|
`There are currently no users. Create one with ${colors.bold(
|
||||||
|
"thelounge add <name>"
|
||||||
|
)}.`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reload all users. Existing users will only have their passwords reloaded.
|
// Reload all users. Existing users will only have their passwords reloaded.
|
||||||
|
@ -73,6 +73,8 @@ describe("Network", function() {
|
|||||||
|
|
||||||
it("lockNetwork should be enforced when validating", function() {
|
it("lockNetwork should be enforced when validating", function() {
|
||||||
Helper.config.lockNetwork = true;
|
Helper.config.lockNetwork = true;
|
||||||
|
|
||||||
|
// Make sure we lock in private mode
|
||||||
Helper.config.public = false;
|
Helper.config.public = false;
|
||||||
|
|
||||||
const network = new Network({
|
const network = new Network({
|
||||||
@ -87,6 +89,7 @@ describe("Network", function() {
|
|||||||
expect(network.tls).to.be.true;
|
expect(network.tls).to.be.true;
|
||||||
expect(network.rejectUnauthorized).to.be.true;
|
expect(network.rejectUnauthorized).to.be.true;
|
||||||
|
|
||||||
|
// Make sure we lock in public mode (also resets public=true for other tests)
|
||||||
Helper.config.public = true;
|
Helper.config.public = true;
|
||||||
|
|
||||||
const network2 = new Network({
|
const network2 = new Network({
|
||||||
@ -96,7 +99,6 @@ describe("Network", function() {
|
|||||||
expect(network2.host).to.equal("chat.freenode.net");
|
expect(network2.host).to.equal("chat.freenode.net");
|
||||||
|
|
||||||
Helper.config.lockNetwork = false;
|
Helper.config.lockNetwork = false;
|
||||||
Helper.config.public = false;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("editing a network should enforce correct types", function() {
|
it("editing a network should enforce correct types", function() {
|
||||||
|
@ -150,6 +150,11 @@ describe("LDAP authentication plugin", function() {
|
|||||||
Helper.config.ldap.primaryKey = primaryKey;
|
Helper.config.ldap.primaryKey = primaryKey;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
afterEach(function() {
|
||||||
|
Helper.config.public = true;
|
||||||
|
Helper.config.ldap.enable = false;
|
||||||
|
});
|
||||||
|
|
||||||
describe("LDAP authentication availability", function() {
|
describe("LDAP authentication availability", function() {
|
||||||
it("checks that the configuration is correctly tied to isEnabled()", function() {
|
it("checks that the configuration is correctly tied to isEnabled()", function() {
|
||||||
Helper.config.ldap.enable = true;
|
Helper.config.ldap.enable = true;
|
||||||
|
@ -56,6 +56,10 @@ describe("Image storage", function() {
|
|||||||
Helper.config.prefetchStorage = true;
|
Helper.config.prefetchStorage = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
afterEach(function() {
|
||||||
|
Helper.config.prefetchStorage = false;
|
||||||
|
});
|
||||||
|
|
||||||
it("should store the thumbnail", function(done) {
|
it("should store the thumbnail", function(done) {
|
||||||
const port = this.port;
|
const port = this.port;
|
||||||
const message = this.irc.createMessage({
|
const message = this.irc.createMessage({
|
||||||
|
@ -52,11 +52,6 @@ describe("Server", function() {
|
|||||||
|
|
||||||
let client;
|
let client;
|
||||||
|
|
||||||
before((done) => {
|
|
||||||
Helper.config.public = true;
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
client = io(webURL, {
|
client = io(webURL, {
|
||||||
path: "/socket.io/",
|
path: "/socket.io/",
|
||||||
|
Loading…
Reference in New Issue
Block a user