mirror of
https://github.com/hack-chat/main.git
synced 2024-03-22 13:20:33 +08:00
Modify changenick to allow the changing of the name's case
This commit is contained in:
parent
015822c70a
commit
8a7a5a0328
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user