From 773b414a13b575697d6d66a8cb967c7bc2b36436 Mon Sep 17 00:00:00 2001 From: sudokoko Date: Fri, 29 Mar 2024 22:46:57 -0400 Subject: [PATCH] Add read-only check to /postComment in slot page controller --- .../Controllers/SlotPageController.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ProjectLighthouse.Servers.Website/Controllers/SlotPageController.cs b/ProjectLighthouse.Servers.Website/Controllers/SlotPageController.cs index 66eafbc0..7385f9c8 100644 --- a/ProjectLighthouse.Servers.Website/Controllers/SlotPageController.cs +++ b/ProjectLighthouse.Servers.Website/Controllers/SlotPageController.cs @@ -10,7 +10,7 @@ using LBPUnion.ProjectLighthouse.Types.Logging; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; -// I would like to apologize in advance for anyone dealing with this file. +// I would like to apologize in advance for anyone dealing with this file. // Theres probably a better way to do this with delegates but I'm tired. // TODO: Clean up this file // - jvyden @@ -63,6 +63,9 @@ public class SlotPageController : ControllerBase WebTokenEntity? token = this.database.WebTokenFromRequest(this.Request); if (token == null) return this.Redirect("~/login"); + // Deny request if in read-only mode + if (ServerConfiguration.Instance.UserGeneratedContentLimits.ReadOnlyMode) return this.Redirect("~/slot/" + id); + if (msg == null) { Logger.Error($"Refusing to post comment from {token.UserId} on level {id}, {nameof(msg)} is null", LogArea.Comments);