Prevent users from uploading over the amount of entitled slots

This commit is contained in:
jvyden 2021-12-11 11:42:56 -05:00
commit f83bd15bc1
No known key found for this signature in database
GPG key ID: 18BCF2BE0262B278

View file

@ -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();