mirror of
https://github.com/thelounge/thelounge
synced 2024-11-26 22:10:22 +00:00
Merge pull request #3918 from ashwinikammar/ashwini/fix_username
Make usernames case-insensitive when logging in
This commit is contained in:
commit
b6bd869d5f
2 changed files with 28 additions and 2 deletions
|
@ -34,18 +34,40 @@ ClientManager.prototype.init = function (identHandler, sockets) {
|
||||||
};
|
};
|
||||||
|
|
||||||
ClientManager.prototype.findClient = function (name) {
|
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 () {
|
ClientManager.prototype.loadUsers = function () {
|
||||||
const users = this.getUsers();
|
let users = this.getUsers();
|
||||||
|
|
||||||
if (users.length === 0) {
|
if (users.length === 0) {
|
||||||
log.info(
|
log.info(
|
||||||
`There are currently no users. Create one with ${colors.bold("thelounge add <name>")}.`
|
`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
|
// This callback is used by Auth plugins to load users they deem acceptable
|
||||||
const callbackLoadUser = (user) => {
|
const callbackLoadUser = (user) => {
|
||||||
this.loadUser(user);
|
this.loadUser(user);
|
||||||
|
|
|
@ -803,6 +803,10 @@ function performAuthentication(data) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (typeof data.user !== "string") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const authCallback = (success) => {
|
const authCallback = (success) => {
|
||||||
// Authorization failed
|
// Authorization failed
|
||||||
if (!success) {
|
if (!success) {
|
||||||
|
|
Loading…
Reference in a new issue