diff --git a/ProjectLighthouse/Pages/UserPage.cshtml.cs b/ProjectLighthouse/Pages/UserPage.cshtml.cs
index 0240ab59..e903ff09 100644
--- a/ProjectLighthouse/Pages/UserPage.cshtml.cs
+++ b/ProjectLighthouse/Pages/UserPage.cshtml.cs
@@ -24,8 +24,9 @@ namespace LBPUnion.ProjectLighthouse.Pages
public async Task OnGet([FromRoute] int userId)
{
+ bool canViewBannedUsers = this.User != null && this.User.IsAdmin;
this.ProfileUser = await this.Database.Users.FirstOrDefaultAsync(u => u.UserId == userId);
- if (this.ProfileUser == null) return this.NotFound();
+ if (this.ProfileUser == null || !canViewBannedUsers && this.ProfileUser.Banned) return this.NotFound();
this.Photos = await this.Database.Photos.OrderByDescending(p => p.Timestamp).Where(p => p.CreatorId == userId).Take(5).ToListAsync();
this.Comments = await this.Database.Comments.Include
diff --git a/ProjectLighthouse/Startup.cs b/ProjectLighthouse/Startup.cs
index fe68aea5..cecb0370 100644
--- a/ProjectLighthouse/Startup.cs
+++ b/ProjectLighthouse/Startup.cs
@@ -87,11 +87,34 @@ namespace LBPUnion.ProjectLighthouse
Stopwatch requestStopwatch = new();
requestStopwatch.Start();
+ context.Request.EnableBuffering(); // Allows us to reset the position of Request.Body for later logging
+
// Log all headers.
// foreach (KeyValuePair header in context.Request.Headers) Logger.Log($"{header.Key}: {header.Value}");
- context.Request.EnableBuffering(); // Allows us to reset the position of Request.Body for later logging
+ await next(context); // Handle the request so we can get the status code from it
+ requestStopwatch.Stop();
+
+ Logger.Log
+ (
+ $"{context.Response.StatusCode}, {requestStopwatch.ElapsedMilliseconds}ms: {context.Request.Method} {context.Request.Path}{context.Request.QueryString}",
+ LoggerLevelHttp.Instance
+ );
+
+ if (context.Request.Method == "POST")
+ {
+ context.Request.Body.Position = 0;
+ Logger.Log(await new StreamReader(context.Request.Body).ReadToEndAsync(), LoggerLevelHttp.Instance);
+ }
+ }
+ );
+
+ // Digest check
+ app.Use
+ (
+ async (context, next) =>
+ {
// Client digest check.
if (!context.Request.Cookies.TryGetValue("MM_AUTH", out string authCookie)) authCookie = string.Empty;
string digestPath = context.Request.Path;
@@ -119,7 +142,7 @@ namespace LBPUnion.ProjectLighthouse
Stream oldResponseStream = context.Response.Body;
context.Response.Body = responseBuffer;
- await next(); // Handle the request so we can get the status code from it
+ await next(context); // Handle the request so we can get the server digest hash
// Compute the server digest hash.
if (computeDigests)
@@ -138,7 +161,13 @@ namespace LBPUnion.ProjectLighthouse
responseBuffer.Position = 0;
await responseBuffer.CopyToAsync(oldResponseStream);
context.Response.Body = oldResponseStream;
+ }
+ );
+ app.Use
+ (
+ async (context, next) =>
+ {
#nullable enable
// Log LastContact for LBP1. This is done on LBP2/3/V on a Match request.
if (context.Request.Path.ToString().StartsWith("/LITTLEBIGPLANETPS3_XML"))
@@ -153,19 +182,7 @@ namespace LBPUnion.ProjectLighthouse
}
#nullable disable
- requestStopwatch.Stop();
-
- Logger.Log
- (
- $"{context.Response.StatusCode}, {requestStopwatch.ElapsedMilliseconds}ms: {context.Request.Method} {context.Request.Path}{context.Request.QueryString}",
- LoggerLevelHttp.Instance
- );
-
- if (context.Request.Method == "POST")
- {
- context.Request.Body.Position = 0;
- Logger.Log(await new StreamReader(context.Request.Body).ReadToEndAsync(), LoggerLevelHttp.Instance);
- }
+ await next(context);
}
);
diff --git a/ProjectLighthouse/Types/User.cs b/ProjectLighthouse/Types/User.cs
index 726c706e..b941d656 100644
--- a/ProjectLighthouse/Types/User.cs
+++ b/ProjectLighthouse/Types/User.cs
@@ -125,6 +125,10 @@ namespace LBPUnion.ProjectLighthouse.Types
}
#nullable disable
+ public bool Banned { get; set; }
+
+ public string BannedReason { get; set; }
+
public string Serialize(GameVersion gameVersion = GameVersion.LittleBigPlanet1)
{
string user = LbpSerializer.TaggedStringElement("npHandle", this.Username, "icon", this.IconHash) +