mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-02 09:08:18 +00:00
fix: kick_player can target a disconnected account by publicId (#4409)
## Description: kick_player resolved a targetPublicID only against activeClients, but a client is dropped from activeClients on socket close (so players technically can disconnect right before getting kicked, then reconnect at a later point and continue playing), aka a disconnected account cannot not be kicked. Fall back to allClients (which persists) so the kick lands and bans the persistentID, blocking rejoin and reconnect. ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory ## Please put your Discord username so you can be contacted if a bug or regression is found: zixer._
This commit is contained in:
@@ -276,12 +276,13 @@ export class GameServer {
|
||||
error: "only the lobby creator or an admin can kick players",
|
||||
};
|
||||
}
|
||||
// Resolve the target to a live clientID: an explicit clientID, or an
|
||||
// account publicId matched against the connected clients (for callers
|
||||
// that know the account but not the per-session clientID).
|
||||
// Resolve the target to a clientID: an explicit clientID, or an account
|
||||
// publicId matched against allClients (a superset of activeClients that
|
||||
// retains disconnected players), so a disconnected account can still be
|
||||
// kicked — its persistentID is banned, blocking rejoin/reconnect.
|
||||
let target = stamped.targetClientID;
|
||||
if (target === undefined && stamped.targetPublicID !== undefined) {
|
||||
target = this.activeClients.find(
|
||||
target = [...this.allClients.values()].find(
|
||||
(c) => c.publicId === stamped.targetPublicID,
|
||||
)?.clientID;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user