From f5ccf925bd74a1f7d8da51e7469a343148ff0566 Mon Sep 17 00:00:00 2001 From: Enerdy Date: Mon, 15 Oct 2018 14:33:32 +0100 Subject: [PATCH 1/2] Logout players when their user account is removed --- TShockAPI/DB/UserManager.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/TShockAPI/DB/UserManager.cs b/TShockAPI/DB/UserManager.cs index 0c0dc5ff..4aa09dee 100644 --- a/TShockAPI/DB/UserManager.cs +++ b/TShockAPI/DB/UserManager.cs @@ -95,13 +95,17 @@ namespace TShockAPI.DB { try { - var tempuser = GetUserAccount(account); + // Logout any player logged in as the account to be removed + TShock.Players.Where(p => p?.IsLoggedIn == true && p.Account.Name == account.Name).ForEach(p => p.Logout()); + + UserAccount tempuser = GetUserAccount(account); int affected = _database.Query("DELETE FROM Users WHERE Username=@0", account.Name); if (affected < 1) throw new UserAccountNotExistException(account.Name); Hooks.AccountHooks.OnAccountDelete(tempuser); + } catch (Exception ex) { From 659e1ebd613317e0ecce0470042d942dcd9c1e5a Mon Sep 17 00:00:00 2001 From: Rodrigo Rente Date: Mon, 15 Oct 2018 15:20:21 +0100 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 52da3276..79f36e88 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -89,6 +89,7 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin * Enabled banning unregistered users (@QuiCM) * Added filtering and validation on packet 96 (Teleport player through portal) (@QuiCM) * Update tracker now uses TLS (@pandabear41) +* When deleting an user account, any player logged in to that account is now logged out properly (@Enerdy) ## TShock 4.3.25 * Fixed a critical exploit in the Terraria protocol that could cause massive unpreventable world corruption as well as a number of other problems. Thanks to @bartico6 for reporting. Fixed by the efforts of @QuiCM, @hakusaro, and tips in the right directioon from @bartico6.