From ad7cfa93304fd762bd01345537d0ab58d3f53746 Mon Sep 17 00:00:00 2001 From: jvyden Date: Fri, 20 May 2022 22:35:39 -0400 Subject: [PATCH] Fix slots page breaking when not logged in --- .../Pages/Partials/SlotCardPartial.cshtml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/ProjectLighthouse.Servers.Website/Pages/Partials/SlotCardPartial.cshtml b/ProjectLighthouse.Servers.Website/Pages/Partials/SlotCardPartial.cshtml index 96a09d5f..6e469d63 100644 --- a/ProjectLighthouse.Servers.Website/Pages/Partials/SlotCardPartial.cshtml +++ b/ProjectLighthouse.Servers.Website/Pages/Partials/SlotCardPartial.cshtml @@ -7,15 +7,21 @@ @model LBPUnion.ProjectLighthouse.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"]!; bool showLink = (bool?)ViewData["ShowLink"] ?? false;