File tree Expand file tree Collapse file tree 5 files changed +15
-13
lines changed
ProjectLighthouse.Servers.GameServer
ProjectLighthouse/Types/Entities/Profile Expand file tree Collapse file tree 5 files changed +15
-13
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change 11using LBPUnion . ProjectLighthouse . Database ;
22using LBPUnion . ProjectLighthouse . Extensions ;
33using LBPUnion . ProjectLighthouse . Servers . GameServer . Helpers ;
4+ using LBPUnion . ProjectLighthouse . Helpers ;
45using LBPUnion . ProjectLighthouse . Types . Entities . Profile ;
56using LBPUnion . ProjectLighthouse . Types . Entities . Token ;
67using 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
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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 ( '.' ) ;
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments