Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make usernames case-insensitive when logging in #3918

Merged
merged 1 commit into from Jul 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 24 additions & 2 deletions src/clientManager.js
Expand Up @@ -34,18 +34,40 @@ ClientManager.prototype.init = function (identHandler, sockets) {
};

ClientManager.prototype.findClient = function (name) {
return this.clients.find((u) => u.name === name);
name = name.toLowerCase();
return this.clients.find((u) => u.name.toLowerCase() === name);
};

ClientManager.prototype.loadUsers = function () {
const users = this.getUsers();
let users = this.getUsers();

if (users.length === 0) {
log.info(
`There are currently no users. Create one with ${colors.bold("thelounge add <name>")}.`
);

return;
}

const alreadySeenUsers = new Set();
users = users.filter((user) => {
user = user.toLowerCase();

if (alreadySeenUsers.has(user)) {
log.error(
`There is more than one user named "${colors.bold(
user
)}". Usernames are now case insensitive, duplicate users will not load.`
);

return false;
}

alreadySeenUsers.add(user);

return true;
});

// This callback is used by Auth plugins to load users they deem acceptable
const callbackLoadUser = (user) => {
this.loadUser(user);
Expand Down
4 changes: 4 additions & 0 deletions src/server.js
Expand Up @@ -803,6 +803,10 @@ function performAuthentication(data) {
return;
}

if (typeof data.user !== "string") {
return;
}

const authCallback = (success) => {
// Authorization failed
if (!success) {
Expand Down