Skip to content

Commit

Permalink
fix: 드립 삭제 권한 설정
Browse files Browse the repository at this point in the history
  • Loading branch information
ProdMoon committed Jun 30, 2024
1 parent 59c71c7 commit 3c63b79
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Controllers/Api/DliibController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public async Task<ActionResult<Dliib>> PostDliib(Dliib dliib)
}

[HttpDelete("{id}")]
[Authorize]
public async Task<IActionResult> DeleteDliib(int id)
{
var dliib = await db.Dliibs.FindAsync(id);
Expand All @@ -110,6 +111,12 @@ public async Task<IActionResult> DeleteDliib(int id)
return NotFound();
}

var user = await db.Users.FirstOrDefaultAsync(x => x.NormalizedUserName == User.Identity.Name);

Check warning on line 114 in Controllers/Api/DliibController.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.
if (dliib.Author != user)
{
return Unauthorized();
}

db.Dliibs.Remove(dliib);
await db.SaveChangesAsync();

Expand Down

0 comments on commit 3c63b79

Please sign in to comment.