diff --git a/ProjectLighthouse.Servers.GameServer/Startup/GameServerStartup.cs b/ProjectLighthouse.Servers.GameServer/Startup/GameServerStartup.cs index 9fcf4a66..0868d72d 100644 --- a/ProjectLighthouse.Servers.GameServer/Startup/GameServerStartup.cs +++ b/ProjectLighthouse.Servers.GameServer/Startup/GameServerStartup.cs @@ -73,7 +73,7 @@ public class GameServerStartup async (context, next) => { // Client digest check. - if (!context.Request.Cookies.TryGetValue("MM_AUTH", out string authCookie)) authCookie = string.Empty; + if (!context.Request.Cookies.TryGetValue("MM_AUTH", out string? authCookie) || authCookie == null) authCookie = string.Empty; string digestPath = context.Request.Path; Stream body = context.Request.Body; diff --git a/ProjectLighthouse.Servers.Website/Pages/Partials/CommentsPartial.cshtml b/ProjectLighthouse.Servers.Website/Pages/Partials/CommentsPartial.cshtml index dfa9bc3c..70e1cfe3 100644 --- a/ProjectLighthouse.Servers.Website/Pages/Partials/CommentsPartial.cshtml +++ b/ProjectLighthouse.Servers.Website/Pages/Partials/CommentsPartial.cshtml @@ -41,7 +41,8 @@ HttpUtility.HtmlDecode(comment.getComment(), messageWriter); string decodedMessage = messageWriter.ToString(); - string url = Url.RouteUrl(ViewContext.RouteData.Values); + string? url = Url.RouteUrl(ViewContext.RouteData.Values); + if (url == null) continue; int rating = comment.ThumbsUp - comment.ThumbsDown; diff --git a/ProjectLighthouse.Servers.Website/Pages/Partials/SlotCardPartial.cshtml b/ProjectLighthouse.Servers.Website/Pages/Partials/SlotCardPartial.cshtml index 7098ef52..6d850c1a 100644 --- a/ProjectLighthouse.Servers.Website/Pages/Partials/SlotCardPartial.cshtml +++ b/ProjectLighthouse.Servers.Website/Pages/Partials/SlotCardPartial.cshtml @@ -5,24 +5,17 @@ @model LBPUnion.ProjectLighthouse.Types.Levels.Slot @{ - User user = (User)ViewData["User"]; + User user = (User)ViewData["User"]!; await using Database database = new(); string slotName = string.IsNullOrEmpty(Model.Name) ? "Unnamed Level" : Model.Name; bool isMobile = (bool?)ViewData["IsMobile"] ?? false; - bool isQueued = false; - bool isHearted = false; + bool isQueued = await database.QueuedLevels.FirstOrDefaultAsync(h => h.SlotId == Model.SlotId && h.UserId == user.UserId) != null; + bool isHearted = await database.HeartedLevels.FirstOrDefaultAsync(h => h.SlotId == Model.SlotId && h.UserId == user.UserId) != null; - if (user != null) - { - isQueued = await database.QueuedLevels.FirstOrDefaultAsync(h => h.SlotId == Model.SlotId && h.UserId == user.UserId) != null; - - isHearted = await database.HeartedLevels.FirstOrDefaultAsync(h => h.SlotId == Model.SlotId && h.UserId == user.UserId) != null; - } - - string callbackUrl = (string)ViewData["CallbackUrl"]; + string callbackUrl = (string)ViewData["CallbackUrl"]!; bool showLink = (bool?)ViewData["ShowLink"] ?? false; string iconHash = Model.IconHash; diff --git a/ProjectLighthouse.Servers.Website/Pages/PhotosPage.cshtml b/ProjectLighthouse.Servers.Website/Pages/PhotosPage.cshtml index d017c117..95542724 100644 --- a/ProjectLighthouse.Servers.Website/Pages/PhotosPage.cshtml +++ b/ProjectLighthouse.Servers.Website/Pages/PhotosPage.cshtml @@ -26,10 +26,10 @@ @if (Model.PageNumber != 0) { - Previous Page + Previous Page } @(Model.PageNumber + 1) / @(Model.PageAmount) @if (Model.PageNumber < Model.PageAmount - 1) { - Next Page + Next Page } \ No newline at end of file diff --git a/ProjectLighthouse.Servers.Website/Pages/RegisterForm.cshtml.cs b/ProjectLighthouse.Servers.Website/Pages/RegisterForm.cshtml.cs index dd40e66d..9f850884 100644 --- a/ProjectLighthouse.Servers.Website/Pages/RegisterForm.cshtml.cs +++ b/ProjectLighthouse.Servers.Website/Pages/RegisterForm.cshtml.cs @@ -15,7 +15,7 @@ public class RegisterForm : BaseLayout public RegisterForm(Database database) : base(database) {} - public string Error { get; private set; } + public string? Error { get; private set; } [UsedImplicitly] [SuppressMessage("ReSharper", "SpecifyStringComparison")] @@ -54,7 +54,7 @@ public class RegisterForm : BaseLayout } if (ServerConfiguration.Instance.Mail.MailEnabled && - await this.Database.Users.FirstOrDefaultAsync(u => u.EmailAddress.ToLower() == emailAddress.ToLower()) != null) + await this.Database.Users.FirstOrDefaultAsync(u => u.EmailAddress != null && u.EmailAddress.ToLower() == emailAddress.ToLower()) != null) { this.Error = "The email address you've chosen is already taken."; return this.Page(); diff --git a/ProjectLighthouse.Servers.Website/Pages/SlotPage.cshtml b/ProjectLighthouse.Servers.Website/Pages/SlotPage.cshtml index cf2de100..b3c70042 100644 --- a/ProjectLighthouse.Servers.Website/Pages/SlotPage.cshtml +++ b/ProjectLighthouse.Servers.Website/Pages/SlotPage.cshtml @@ -10,8 +10,8 @@ Layout = "Layouts/BaseLayout"; Model.ShowTitleInPage = false; - Model.Title = Model.Slot.Name; - Model.Description = Model.Slot.Description; + Model.Title = Model.Slot?.Name ?? ""; + Model.Description = Model.Slot?.Description ?? ""; bool isMobile = this.Request.IsMobile(); } @@ -22,7 +22,7 @@ "User", Model.User }, { - "CallbackUrl", $"~/slot/{Model.Slot.SlotId}" + "CallbackUrl", $"~/slot/{Model.Slot?.SlotId}" }, { "ShowLink", false @@ -37,14 +37,15 @@
@HttpUtility.HtmlDecode(string.IsNullOrEmpty(Model.Slot.Description) ? "This level has no description." : Model.Slot.Description)
+@HttpUtility.HtmlDecode(string.IsNullOrEmpty(Model.Slot?.Description) ? "This level has no description." : Model.Slot.Description)
This level has no tags.
@@ -86,13 +87,13 @@ @for(int i = 0; i < Model.Reviews.Count; i++) { Review review = Model.Reviews[i]; - string faceHash = review.Thumb switch { + string faceHash = (review.Thumb switch { -1 => review.Reviewer?.BooHash, 0 => review.Reviewer?.MehHash, 1 => review.Reviewer?.YayHash, _ => throw new ArgumentOutOfRangeException(), - }; + }) ?? ""; if (string.IsNullOrWhiteSpace(faceHash)) { @@ -168,7 +169,7 @@