cvmts: fix rename oddities

This commit is contained in:
Elijah R
2025-03-21 21:28:13 -04:00
parent 10dd3c2489
commit 5705971be6
2 changed files with 7 additions and 7 deletions

View File

@@ -477,7 +477,7 @@ export default class CollabVMServer implements IProtocolMessageHandler {
this.renameUser(user, undefined); this.renameUser(user, undefined);
return; return;
} }
this.renameUser(user, newName!); this.renameUser(user, newName);
} }
onChat(user: User, message: string): void { onChat(user: User, message: string): void {
@@ -719,6 +719,8 @@ export default class CollabVMServer implements IProtocolMessageHandler {
let oldname: any; let oldname: any;
if (hadName) oldname = client.username; if (hadName) oldname = client.username;
let status = ProtocolRenameStatus.Ok;
if (!newName) { if (!newName) {
client.assignGuestName(this.getUsernameList()); client.assignGuestName(this.getUsernameList());
} else { } else {
@@ -728,8 +730,6 @@ export default class CollabVMServer implements IProtocolMessageHandler {
return; return;
} }
let status = ProtocolRenameStatus.Ok;
if (this.getUsernameList().indexOf(newName) !== -1) { if (this.getUsernameList().indexOf(newName) !== -1) {
client.assignGuestName(this.getUsernameList()); client.assignGuestName(this.getUsernameList());
if (client.connectedToNode) { if (client.connectedToNode) {
@@ -742,10 +742,10 @@ export default class CollabVMServer implements IProtocolMessageHandler {
client.assignGuestName(this.getUsernameList()); client.assignGuestName(this.getUsernameList());
status = ProtocolRenameStatus.UsernameNotAllowed; status = ProtocolRenameStatus.UsernameNotAllowed;
} else client.username = newName; } else client.username = newName;
client.protocol.sendSelfRename(status, client.username!, client.rank);
} }
client.protocol.sendSelfRename(status, client.username!, client.rank);
if (hadName) { if (hadName) {
this.logger.info(`Rename ${client.IP.address} from ${oldname} to ${client.username}`); 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)); if (announce) this.clients.forEach((c) => c.protocol.sendRename(oldname, client.username!, client.rank));

View File

@@ -292,11 +292,11 @@ export class GuacamoleProtocol extends ProtocolBase implements IProtocol {
} }
sendSelfRename(status: ProtocolRenameStatus, newUsername: string, rank: Rank): void { 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 { 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 { sendListResponse(list: ListEntry[]): void {