From 8a7a5a0328422dd3167fe67155ad6b4751fff6e4 Mon Sep 17 00:00:00 2001 From: MinusGix Date: Thu, 2 Jul 2020 07:30:55 -0500 Subject: [PATCH] Modify changenick to allow the changing of the name's case --- server/src/commands/core/changenick.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/server/src/commands/core/changenick.js b/server/src/commands/core/changenick.js index 9cfa929..bbd3ec3 100644 --- a/server/src/commands/core/changenick.js +++ b/server/src/commands/core/changenick.js @@ -18,6 +18,8 @@ export async function run(core, server, socket, data) { return true; } + const previousNick = socket.nick; + // make sure requested nickname meets standards const newNick = data.nick.trim(); if (!UAC.verifyNickname(newNick)) { @@ -38,10 +40,19 @@ export async function run(core, server, socket, data) { }, socket); } + if (newNick == previousNick) { + return server.reply({ + cmd: 'warn', + text: 'You already have that name', + }, socket); + } + // find any sockets that have the same nickname const userExists = server.findSockets({ 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