From 5705971be6fc6b0c7eeec6a9ccb211ab75aa1093 Mon Sep 17 00:00:00 2001 From: Elijah R Date: Fri, 21 Mar 2025 21:28:13 -0400 Subject: [PATCH] cvmts: fix rename oddities --- cvmts/src/CollabVMServer.ts | 10 +++++----- cvmts/src/protocol/GuacamoleProtocol.ts | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cvmts/src/CollabVMServer.ts b/cvmts/src/CollabVMServer.ts index 8806a62..e1cf409 100644 --- a/cvmts/src/CollabVMServer.ts +++ b/cvmts/src/CollabVMServer.ts @@ -477,7 +477,7 @@ export default class CollabVMServer implements IProtocolMessageHandler { this.renameUser(user, undefined); return; } - this.renameUser(user, newName!); + this.renameUser(user, newName); } onChat(user: User, message: string): void { @@ -719,6 +719,8 @@ export default class CollabVMServer implements IProtocolMessageHandler { let oldname: any; if (hadName) oldname = client.username; + let status = ProtocolRenameStatus.Ok; + if (!newName) { client.assignGuestName(this.getUsernameList()); } else { @@ -728,8 +730,6 @@ export default class CollabVMServer implements IProtocolMessageHandler { return; } - let status = ProtocolRenameStatus.Ok; - if (this.getUsernameList().indexOf(newName) !== -1) { client.assignGuestName(this.getUsernameList()); if (client.connectedToNode) { @@ -742,10 +742,10 @@ export default class CollabVMServer implements IProtocolMessageHandler { client.assignGuestName(this.getUsernameList()); status = ProtocolRenameStatus.UsernameNotAllowed; } else client.username = newName; - - client.protocol.sendSelfRename(status, client.username!, client.rank); } + client.protocol.sendSelfRename(status, client.username!, client.rank); + if (hadName) { this.logger.info(`Rename ${client.IP.address} from ${oldname} to ${client.username}`); if (announce) this.clients.forEach((c) => c.protocol.sendRename(oldname, client.username!, client.rank)); diff --git a/cvmts/src/protocol/GuacamoleProtocol.ts b/cvmts/src/protocol/GuacamoleProtocol.ts index e5c1998..4735a37 100644 --- a/cvmts/src/protocol/GuacamoleProtocol.ts +++ b/cvmts/src/protocol/GuacamoleProtocol.ts @@ -292,11 +292,11 @@ export class GuacamoleProtocol extends ProtocolBase implements IProtocol { } sendSelfRename(status: ProtocolRenameStatus, newUsername: string, rank: Rank): void { - this.user?.sendMsg(cvm.guacEncode('rename', '0', status.toString(), newUsername, rank.toString())); + this.user?.sendMsg(cvm.guacEncode('rename', '0', status.toString(), newUsername)); } sendRename(oldUsername: string, newUsername: string, rank: Rank): void { - this.user?.sendMsg(cvm.guacEncode('rename', '1', oldUsername, newUsername, rank.toString())); + this.user?.sendMsg(cvm.guacEncode('rename', '1', oldUsername, newUsername)); } sendListResponse(list: ListEntry[]): void {