fix update just if ressource is owned by user

master
remrem 10 months ago
parent 388e96a48a
commit ea06ee4cfe

@ -11,7 +11,6 @@ use App\Entity\Post;
use App\Form\Type\PostType; use App\Form\Type\PostType;
use App\Form\CommentType; use App\Form\CommentType;
use App\Form\Type\SimpleSearchType; use App\Form\Type\SimpleSearchType;
use phpDocumentor\Reflection\DocBlock\Tags\Return_;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
class PostController extends AbstractController class PostController extends AbstractController
@ -100,6 +99,13 @@ class PostController extends AbstractController
$post = $this->em->getRepository(Post::class)->find($id); $post = $this->em->getRepository(Post::class)->find($id);
$form = $this->createForm(PostType::class, $post); $form = $this->createForm(PostType::class, $post);
if ($this->getUser() !== $post->getProfil())
{
return $this->redirectToRoute('display_post', [
'id' => $id
]);
}
$form->handleRequest($request); $form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) { if ($form->isSubmitted() && $form->isValid()) {
//$dateNow = new DateTime(); //$dateNow = new DateTime();

Binary file not shown.
Loading…
Cancel
Save