mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-29 08:28:39 +00:00
Check if user owns level before unpublishing
This commit is contained in:
parent
54a61570bd
commit
8f7d536f50
1 changed files with 5 additions and 0 deletions
|
@ -111,8 +111,13 @@ namespace LBPUnion.ProjectLighthouse.Controllers
|
|||
[HttpPost("unpublish/{id:int}")]
|
||||
public async Task<IActionResult> 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);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue