From 68fc3519f7333e25e7397e4fa866b9493cc57c5c Mon Sep 17 00:00:00 2001 From: "aurian.jault" Date: Thu, 13 Jun 2024 08:05:24 +0200 Subject: [PATCH] Added athentication on DELETE post --- src/Controller/PostController.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Controller/PostController.php b/src/Controller/PostController.php index 50f58ab..3dd31f5 100644 --- a/src/Controller/PostController.php +++ b/src/Controller/PostController.php @@ -79,9 +79,11 @@ class PostController extends AbstractController public function removePost(int $id): Response { $post = $this->em->getRepository(Post::class)->find($id); - $this->em->remove($post); - $this->em->flush(); - + if($post->getProfil()->getId() === $this->getUser()->getId()) + { + $this->em->remove($post); + $this->em->flush(); + } return new Response(); } }