diff --git a/ProjectLighthouse/Controllers/PublishController.cs b/ProjectLighthouse/Controllers/PublishController.cs index a19b7bb8..da4d9b0c 100644 --- a/ProjectLighthouse/Controllers/PublishController.cs +++ b/ProjectLighthouse/Controllers/PublishController.cs @@ -111,8 +111,13 @@ namespace LBPUnion.ProjectLighthouse.Controllers [HttpPost("unpublish/{id:int}")] public async Task Unpublish(int id) { + User user = await this.database.UserFromRequest(this.Request); + if (user == null) return this.StatusCode(403, ""); + Slot slot = await this.database.Slots.Include(s => s.Location).FirstOrDefaultAsync(s => s.SlotId == id); + if (slot.CreatorId != user.UserId) return this.StatusCode(403, ""); + this.database.Locations.Remove(slot.Location); this.database.Slots.Remove(slot);