Skip to content

Commit 1ab8425

Browse files
committed
Quick fixes (awesome name)
1 parent 68dbf50 commit 1ab8425

File tree

5 files changed

+15
-13
lines changed

5 files changed

+15
-13
lines changed

ProjectLighthouse.Servers.GameServer/Controllers/Login/LoginController.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -214,12 +214,6 @@ public async Task<IActionResult> Login()
214214

215215
Logger.Success($"Successfully logged in user {user.Username} as {token.GameVersion} client", LogArea.Login);
216216

217-
string userAgent = this.Request.Headers.UserAgent.ToString();
218-
if (!String.IsNullOrWhiteSpace(userAgent))
219-
{
220-
user.UserAgent = userAgent;
221-
}
222-
223217
await database.SaveChangesAsync();
224218

225219
// Create a new room on LBP2/3/Vita

ProjectLighthouse.Servers.GameServer/Controllers/Login/LogoutController.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using LBPUnion.ProjectLighthouse.Database;
22
using LBPUnion.ProjectLighthouse.Extensions;
33
using LBPUnion.ProjectLighthouse.Servers.GameServer.Helpers;
4+
using LBPUnion.ProjectLighthouse.Helpers;
45
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
56
using LBPUnion.ProjectLighthouse.Types.Entities.Token;
67
using Microsoft.AspNetCore.Authorization;
@@ -32,6 +33,8 @@ public async Task<IActionResult> OnPost()
3233

3334
await LogoutHelper.Logout(token, user, database);
3435

36+
user.LastLogin = TimeHelper.TimestampMillis;
37+
3538
return this.Ok();
3639
}
3740

ProjectLighthouse.Servers.GameServer/Controllers/MessageController.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,13 @@ public async Task<IActionResult> Announce()
7777
{
7878
announceText.Append("This server instance requires the use of the Patchwork plugin for LBP.\n\n");
7979

80-
if (PatchworkHelper.userHasValidPatchworkUserAgent(user.UserAgent))
80+
if (PatchworkHelper.UserHasValidPatchworkUserAgent(this.Request.Headers.UserAgent.ToString()))
8181
{
8282
announceText.Append("It appears you do not have the Patchwork plugin installed correctly." +
83-
"Since this server instance requires it, you will not be able to play until you so.");
83+
"Since this server instance requires it, you will not be able to play until you so.");
84+
85+
await LogoutHelper.Logout(token, user, database);
8486
}
85-
await LogoutHelper.Logout(token, user, database);
8687
}
8788

8889
#if DEBUG

ProjectLighthouse.Servers.GameServer/Helpers/PatchworkHelper.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,15 @@ public static class PatchworkHelper
66
{
77
static int patchworkMajorVer = ServerConfiguration.Instance.PatchworkMajorVersionMinimum;
88
static int patchworkMinorVer = ServerConfiguration.Instance.PatchworkMinorVersionMinimum;
9-
public static bool userHasValidPatchworkUserAgent(string userAgent)
9+
public static bool UserHasValidPatchworkUserAgent(string userAgent)
1010
{
11-
if (userAgent.StartsWith("PatchworkLBP"))
11+
string userAgentPrefix = "PatchworkLBP";
12+
char gameVersion = userAgent[userAgentPrefix.Length];
13+
14+
if (userAgent.StartsWith(userAgentPrefix))
15+
return false;
16+
17+
if (gameVersion is not '1' or '2' or '3' or 'V')
1218
return false;
1319

1420
string[] patchworkVer = userAgent.Split(' ')[1].Split('.');

ProjectLighthouse/Types/Entities/Profile/UserEntity.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ public class UserEntity
2828

2929
public string IconHash { get; set; }
3030

31-
public string UserAgent { get; set;}
32-
3331
/// <summary>
3432
/// Markup that displays the username next to a polaroid with the user's icon.
3533
/// This can be used everywhere markup works ingame, e.g. news or notifications

0 commit comments

Comments
 (0)