1
0
mirror of https://github.com/hack-chat/main.git synced 2024-03-22 13:20:33 +08:00

Merge pull request #105 from MinusGix/change_nick_case

Modify changenick to allow the changing of the name's case
This commit is contained in:
marzavec 2020-07-06 08:31:56 -05:00 committed by GitHub
commit 4e59a3a1e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -18,6 +18,8 @@ export async function run(core, server, socket, data) {
return true; return true;
} }
const previousNick = socket.nick;
// make sure requested nickname meets standards // make sure requested nickname meets standards
const newNick = data.nick.trim(); const newNick = data.nick.trim();
if (!UAC.verifyNickname(newNick)) { if (!UAC.verifyNickname(newNick)) {
@ -38,10 +40,19 @@ export async function run(core, server, socket, data) {
}, socket); }, socket);
} }
if (newNick == previousNick) {
return server.reply({
cmd: 'warn',
text: 'You already have that name',
}, socket);
}
// find any sockets that have the same nickname // find any sockets that have the same nickname
const userExists = server.findSockets({ const userExists = server.findSockets({
channel: socket.channel, channel: socket.channel,
nick: (targetNick) => targetNick.toLowerCase() === newNick.toLowerCase(), nick: (targetNick) => targetNick.toLowerCase() === newNick.toLowerCase() &&
// Allow them to rename themselves to a different case
targetNick != previousNick,
}); });
// return error if found // return error if found