diff --git a/ProjectLighthouse.Servers.GameServer/Controllers/Login/LoginController.cs b/ProjectLighthouse.Servers.GameServer/Controllers/Login/LoginController.cs
index 827f9384..f82e565b 100644
--- a/ProjectLighthouse.Servers.GameServer/Controllers/Login/LoginController.cs
+++ b/ProjectLighthouse.Servers.GameServer/Controllers/Login/LoginController.cs
@@ -214,12 +214,6 @@ public class LoginController : ControllerBase
Logger.Success($"Successfully logged in user {user.Username} as {token.GameVersion} client", LogArea.Login);
- string userAgent = this.Request.Headers.UserAgent.ToString();
- if (!String.IsNullOrWhiteSpace(userAgent))
- {
- user.UserAgent = userAgent;
- }
-
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 2003dc6a..51d2463a 100644
--- a/ProjectLighthouse.Servers.GameServer/Controllers/Login/LogoutController.cs
+++ b/ProjectLighthouse.Servers.GameServer/Controllers/Login/LogoutController.cs
@@ -1,6 +1,7 @@
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Servers.GameServer.Helpers;
+using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
using LBPUnion.ProjectLighthouse.Types.Entities.Token;
using Microsoft.AspNetCore.Authorization;
@@ -32,6 +33,8 @@ public class LogoutController : ControllerBase
await LogoutHelper.Logout(token, user, database);
+ user.LastLogin = TimeHelper.TimestampMillis;
+
return this.Ok();
}
diff --git a/ProjectLighthouse.Servers.GameServer/Controllers/MessageController.cs b/ProjectLighthouse.Servers.GameServer/Controllers/MessageController.cs
index ec7dfaa9..91397fb0 100644
--- a/ProjectLighthouse.Servers.GameServer/Controllers/MessageController.cs
+++ b/ProjectLighthouse.Servers.GameServer/Controllers/MessageController.cs
@@ -77,12 +77,13 @@ along with this program. If not, see .";
{
announceText.Append("This server instance requires the use of the Patchwork plugin for LBP.\n\n");
- if (PatchworkHelper.userHasValidPatchworkUserAgent(user.UserAgent))
+ 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.");
+ "Since this server instance requires it, you will not be able to play until you so.");
+
+ await LogoutHelper.Logout(token, user, database);
}
- await LogoutHelper.Logout(token, user, database);
}
#if DEBUG
diff --git a/ProjectLighthouse.Servers.GameServer/Helpers/PatchworkHelper.cs b/ProjectLighthouse.Servers.GameServer/Helpers/PatchworkHelper.cs
index 3438cade..ca28307d 100644
--- a/ProjectLighthouse.Servers.GameServer/Helpers/PatchworkHelper.cs
+++ b/ProjectLighthouse.Servers.GameServer/Helpers/PatchworkHelper.cs
@@ -6,9 +6,15 @@ public static class PatchworkHelper
{
static int patchworkMajorVer = ServerConfiguration.Instance.PatchworkMajorVersionMinimum;
static int patchworkMinorVer = ServerConfiguration.Instance.PatchworkMinorVersionMinimum;
- public static bool userHasValidPatchworkUserAgent(string userAgent)
+ public static bool UserHasValidPatchworkUserAgent(string userAgent)
{
- if (userAgent.StartsWith("PatchworkLBP"))
+ string userAgentPrefix = "PatchworkLBP";
+ char gameVersion = userAgent[userAgentPrefix.Length];
+
+ if (userAgent.StartsWith(userAgentPrefix))
+ return false;
+
+ if (gameVersion is not '1' or '2' or '3' or 'V')
return false;
string[] patchworkVer = userAgent.Split(' ')[1].Split('.');
diff --git a/ProjectLighthouse/Types/Entities/Profile/UserEntity.cs b/ProjectLighthouse/Types/Entities/Profile/UserEntity.cs
index c1615705..6fb65301 100644
--- a/ProjectLighthouse/Types/Entities/Profile/UserEntity.cs
+++ b/ProjectLighthouse/Types/Entities/Profile/UserEntity.cs
@@ -28,8 +28,6 @@ public class UserEntity
public string IconHash { get; set; }
- public string UserAgent { get; set;}
-
///
/// Markup that displays the username next to a polaroid with the user's icon.
/// This can be used everywhere markup works ingame, e.g. news or notifications