Added athentication on DELETE post

pull/21/head^2
Aurian JAULT 10 months ago
parent 83b0a7f93b
commit 68fc3519f7

@ -79,9 +79,11 @@ class PostController extends AbstractController
public function removePost(int $id): Response public function removePost(int $id): Response
{ {
$post = $this->em->getRepository(Post::class)->find($id); $post = $this->em->getRepository(Post::class)->find($id);
$this->em->remove($post); if($post->getProfil()->getId() === $this->getUser()->getId())
$this->em->flush(); {
$this->em->remove($post);
$this->em->flush();
}
return new Response(); return new Response();
} }
} }

Loading…
Cancel
Save