diff --git a/ProjectLighthouse.Servers.GameServer/Controllers/Login/LoginController.cs b/ProjectLighthouse.Servers.GameServer/Controllers/Login/LoginController.cs index f82e565b..31cc050d 100644 --- a/ProjectLighthouse.Servers.GameServer/Controllers/Login/LoginController.cs +++ b/ProjectLighthouse.Servers.GameServer/Controllers/Login/LoginController.cs @@ -3,6 +3,7 @@ using LBPUnion.ProjectLighthouse.Configuration; using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Helpers; +using LBPUnion.ProjectLighthouse.Servers.GameServer.Helpers; using LBPUnion.ProjectLighthouse.Logging; using LBPUnion.ProjectLighthouse.Tickets; using LBPUnion.ProjectLighthouse.Types.Entities.Profile; @@ -66,6 +67,11 @@ public class LoginController : ControllerBase UserEntity? user; + if (!PatchworkHelper.UserHasValidPatchworkUserAgent(this.Request.Headers.UserAgent.ToString())) + { + return this.Forbid(); + } + switch (npTicket.Platform) { case Platform.RPCS3: @@ -214,6 +220,8 @@ public class LoginController : ControllerBase Logger.Success($"Successfully logged in user {user.Username} as {token.GameVersion} client", LogArea.Login); + user.LastLogin = TimeHelper.TimestampMillis; + await database.SaveChangesAsync(); // Create a new room on LBP2/3/Vita diff --git a/ProjectLighthouse.Servers.GameServer/Controllers/Login/LogoutController.cs b/ProjectLighthouse.Servers.GameServer/Controllers/Login/LogoutController.cs index 51d2463a..029419b1 100644 --- a/ProjectLighthouse.Servers.GameServer/Controllers/Login/LogoutController.cs +++ b/ProjectLighthouse.Servers.GameServer/Controllers/Login/LogoutController.cs @@ -31,12 +31,12 @@ public class LogoutController : ControllerBase UserEntity? user = await this.database.UserFromGameToken(token); if (user == null) return this.Forbid(); - await LogoutHelper.Logout(token, user, database); + user.LastLogout = TimeHelper.TimestampMillis; - user.LastLogin = TimeHelper.TimestampMillis; + await this.database.GameTokens.RemoveWhere(t => t.TokenId == token.TokenId); + await this.database.LastContacts.RemoveWhere(c => c.UserId == token.UserId); return this.Ok(); } - } \ No newline at end of file diff --git a/ProjectLighthouse.Servers.GameServer/Controllers/MessageController.cs b/ProjectLighthouse.Servers.GameServer/Controllers/MessageController.cs index 91397fb0..43ea5b03 100644 --- a/ProjectLighthouse.Servers.GameServer/Controllers/MessageController.cs +++ b/ProjectLighthouse.Servers.GameServer/Controllers/MessageController.cs @@ -1,4 +1,3 @@ -using System.Globalization; using System.Text; using LBPUnion.ProjectLighthouse.Configuration; using LBPUnion.ProjectLighthouse.Database; @@ -8,7 +7,6 @@ using LBPUnion.ProjectLighthouse.Localization; using LBPUnion.ProjectLighthouse.Localization.StringLists; using LBPUnion.ProjectLighthouse.Logging; using LBPUnion.ProjectLighthouse.Serialization; -using LBPUnion.ProjectLighthouse.Servers.GameServer.Helpers; using LBPUnion.ProjectLighthouse.Types.Entities.Notifications; using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using LBPUnion.ProjectLighthouse.Types.Entities.Token; @@ -73,19 +71,6 @@ along with this program. If not, see ."; announceText.Insert(0, BaseLayoutStrings.ReadOnlyWarn.Translate(LocalizationManager.DefaultLang) + "\n\n"); } - if (ServerConfiguration.Instance.RequirePatchworkUserAgent) - { - announceText.Append("This server instance requires the use of the Patchwork plugin for LBP.\n\n"); - - if (!PatchworkHelper.UserHasValidPatchworkUserAgent(this.Request.Headers.UserAgent.ToString())) - { - announceText.Append("It appears you do not have the Patchwork plugin installed correctly." + - "Since this server instance requires it, you will not be able to play until you so."); - - await LogoutHelper.Logout(token, user, database); - } - } - #if DEBUG announceText.Append("\n\n---DEBUG INFO---\n" + $"user.UserId: {token.UserId}\n" + diff --git a/ProjectLighthouse.Servers.GameServer/Helpers/LogoutHelper.cs b/ProjectLighthouse.Servers.GameServer/Helpers/LogoutHelper.cs deleted file mode 100644 index 545aef94..00000000 --- a/ProjectLighthouse.Servers.GameServer/Helpers/LogoutHelper.cs +++ /dev/null @@ -1,18 +0,0 @@ -using LBPUnion.ProjectLighthouse.Helpers; -using LBPUnion.ProjectLighthouse.Database; -using LBPUnion.ProjectLighthouse.Extensions; -using LBPUnion.ProjectLighthouse.Types.Entities.Token; -using LBPUnion.ProjectLighthouse.Types.Entities.Profile; - -namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Helpers; - -public class LogoutHelper -{ - public static async Task Logout(GameTokenEntity token, UserEntity user, DatabaseContext database) - { - user.LastLogout = TimeHelper.TimestampMillis; - - await database.GameTokens.RemoveWhere(t => t.TokenId == token.TokenId); - await database.LastContacts.RemoveWhere(c => c.UserId == token.UserId); - } -} \ No newline at end of file