From f83bd15bc17a0764265608f5b195c32ace3f24d3 Mon Sep 17 00:00:00 2001 From: jvyden Date: Sat, 11 Dec 2021 11:42:56 -0500 Subject: [PATCH] Prevent users from uploading over the amount of entitled slots --- ProjectLighthouse/Controllers/PublishController.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ProjectLighthouse/Controllers/PublishController.cs b/ProjectLighthouse/Controllers/PublishController.cs index 98f490e2..ecf7a66d 100644 --- a/ProjectLighthouse/Controllers/PublishController.cs +++ b/ProjectLighthouse/Controllers/PublishController.cs @@ -9,6 +9,7 @@ using LBPUnion.ProjectLighthouse.Serialization; using LBPUnion.ProjectLighthouse.Types; using LBPUnion.ProjectLighthouse.Types.Levels; using LBPUnion.ProjectLighthouse.Types.Profiles; +using LBPUnion.ProjectLighthouse.Types.Settings; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; @@ -35,6 +36,8 @@ namespace LBPUnion.ProjectLighthouse.Controllers User? user = await this.database.UserFromGameRequest(this.Request); if (user == null) return this.StatusCode(403, ""); + if (user.UsedSlots >= ServerSettings.Instance.EntitledSlots) return this.BadRequest(); + Slot? slot = await this.GetSlotFromBody(); if (slot == null) return this.BadRequest(); // if the level cant be parsed then it obviously cant be uploaded @@ -74,6 +77,8 @@ namespace LBPUnion.ProjectLighthouse.Controllers User user = userAndToken.Value.Item1; GameToken gameToken = userAndToken.Value.Item2; + if (user.UsedSlots >= ServerSettings.Instance.EntitledSlots) return this.BadRequest(); + Slot? slot = await this.GetSlotFromBody(); if (slot?.Location == null) return this.BadRequest();