Merge pull request #1593 from RJacksonm1/reload-passwords-all-proper-like
Ensure passwords are reloaded when updated via CLI
This commit is contained in:
commit
f9be519c2f
@ -51,8 +51,8 @@ ClientManager.prototype.autoloadUsers = function() {
|
|||||||
log.info(noUsersWarning);
|
log.info(noUsersWarning);
|
||||||
}
|
}
|
||||||
|
|
||||||
// New users created since last time users were loaded
|
// Reload all users. Existing users will only have their passwords reloaded.
|
||||||
_.difference(updatedUsers, loaded).forEach((name) => this.loadUser(name));
|
updatedUsers.forEach((name) => this.loadUser(name));
|
||||||
|
|
||||||
// Existing users removed since last time users were loaded
|
// Existing users removed since last time users were loaded
|
||||||
_.difference(loaded, updatedUsers).forEach((name) => {
|
_.difference(loaded, updatedUsers).forEach((name) => {
|
||||||
@ -67,22 +67,30 @@ ClientManager.prototype.autoloadUsers = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
ClientManager.prototype.loadUser = function(name) {
|
ClientManager.prototype.loadUser = function(name) {
|
||||||
const user = readUserConfig(name);
|
const userConfig = readUserConfig(name);
|
||||||
|
|
||||||
if (!user) {
|
if (!userConfig) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let client = this.findClient(name);
|
let client = this.findClient(name);
|
||||||
|
|
||||||
if (client) {
|
if (client) {
|
||||||
log.warn(`Tried to load user ${colors.bold(name)}, which is already loaded.`);
|
if (userConfig.password !== client.config.password) {
|
||||||
return client;
|
/**
|
||||||
|
* If we happen to reload an existing client, make super duper sure we
|
||||||
|
* have their latest password. We're not replacing the entire config
|
||||||
|
* object, because that could have undesired consequences.
|
||||||
|
*
|
||||||
|
* @see https://github.com/thelounge/lounge/issues/598
|
||||||
|
*/
|
||||||
|
client.config.password = userConfig.password;
|
||||||
|
log.info(`Password for user ${colors.bold(name)} was reset.`);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
client = new Client(this, name, userConfig);
|
||||||
|
this.clients.push(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
client = new Client(this, name, user);
|
|
||||||
this.clients.push(client);
|
|
||||||
|
|
||||||
return client;
|
return client;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user