diff --git a/src/Controller/AnswerController.php b/src/Controller/AnswerController.php index fbbf529..579163b 100644 --- a/src/Controller/AnswerController.php +++ b/src/Controller/AnswerController.php @@ -41,8 +41,7 @@ public function modifyAnswer(int $id) $verifAccess = new AccessValidator(); if (!$verifAccess->isValid($idUserAnswer['idUser'] ?? null)) { http_response_code(500); - $this->renderView('500.html.twig'); - exit(); + return $this->renderView('500.html.twig'); } $this->renderView( 'modifyAnswer.html.twig', @@ -74,8 +73,7 @@ public function deleteAnswer(int $id) $verifAccess = new AccessValidator(); if (!$verifAccess->isValid($answerInfo['idUser'] ?? null)) { http_response_code(500); - $this->renderView('500.html.twig'); - exit(); + return $this->renderView('500.html.twig'); } $session = new MessageFlash(); $session->setFlashMessage('Votre réponse a bien été supprimée !', 'success'); diff --git a/src/Controller/BloggerController.php b/src/Controller/BloggerController.php index 66d3a46..964f5af 100644 --- a/src/Controller/BloggerController.php +++ b/src/Controller/BloggerController.php @@ -16,8 +16,7 @@ public function show(int $id) if (!$bloggerInfo) { http_response_code(404); - $this->renderView('404.html.twig'); - exit(); + return $this->renderView('404.html.twig'); } $cookie = $_COOKIE['auth'] ?? null; @@ -50,8 +49,7 @@ public function modifyProfil(int $id) if (!$verifAccess->isValid($bloggerInfo['idUser'])) { http_response_code(500); - $this->renderView('500.html.twig'); - exit(); + return $this->renderView('500.html.twig'); } if ($_SERVER['REQUEST_METHOD'] == 'POST') { @@ -66,8 +64,7 @@ public function modifyProfil(int $id) $checkForm = new FormValidator(); if (!$checkForm->checkModifProfile($_POST)) { - header('Location: /Blog/modify-profil/' . $id); - exit(); + return header('Location: /Blog/modify-profil/' . $id); } $session->setFlashMessage('Votre profil a bien été modifié !', 'success'); $bloggerRepo->modifyProfil($id, $blogger); diff --git a/src/Controller/MailController.php b/src/Controller/MailController.php index a0beffd..f4c99f5 100644 --- a/src/Controller/MailController.php +++ b/src/Controller/MailController.php @@ -31,8 +31,7 @@ public function sendNewPassword() if (!$userRepo->getUserByEmail($email)) { $session = new MessageFlash(); $session->setFlashMessage('Le mail saisi n\'existe pas ! ', 'danger'); - header("Location: /Blog/sign-in"); - exit(); + return header("Location: /Blog/sign-in"); } $randomPassword = new RandomPassword(); diff --git a/src/Controller/PostsController.php b/src/Controller/PostsController.php index 7033f0d..0affc71 100644 --- a/src/Controller/PostsController.php +++ b/src/Controller/PostsController.php @@ -16,8 +16,7 @@ public function show(int $id) $cookie = explode('-----', $cookie); if (!$postInfo) { http_response_code(404); - $this->renderView('404.html.twig'); - exit(); + return $this->renderView('404.html.twig'); } $userName = $post->getUserForAPost($id); $answerRepo = new AnswerRepository(); @@ -57,8 +56,7 @@ public function showAllPosts($page) $hasPost = false; } else if ($paginationConf['overPage']) { http_response_code(404); - $this->renderView('404.html.twig'); - exit(); + return $this->renderView('404.html.twig'); } $this->renderView( @@ -81,8 +79,7 @@ public function createPost() $verifAccess = new AccessValidator(); if ($verifAccess->isValid($_SESSION['id'] ?? $cookie[0]) === false) { http_response_code(500); - $this->renderView(ERR_500); - exit(); + return $this->renderView(ERR_500); } $session = new MessageFlash(); @@ -109,8 +106,7 @@ public function createPost() $checkPost = new FormValidator(); if (!$checkPost->checkPost($post)) { - header('Location: /Blog/create-post'); - exit(); + return header('Location: /Blog/create-post'); } $session = new MessageFlash(); @@ -134,8 +130,7 @@ public function modifyPost(int $id) if (!$verifAccess->isValid($postInfo['idUser'] ?? null)) { http_response_code(500); - $this->renderView(ERR_500); - exit(); + return $this->renderView(ERR_500); } $this->renderView( 'modifyPost.html.twig', @@ -166,8 +161,7 @@ public function modifyPost(int $id) $checkPost = new FormValidator(); if (!$checkPost->checkPost($post)) { - header('Location: /Blog/modify-post/' . $id); - exit(); + return header('Location: /Blog/modify-post/' . $id); } $session = new MessageFlash(); $session->setFlashMessage('Votre post a bien été modifié !', 'alert alert-success'); @@ -184,8 +178,7 @@ public function deletePost(int $id) if (!$verifAccess->isValid($postInfo['idUser'] ?? null)) { http_response_code(500); - $this->renderView(ERR_500); - exit(); + return $this->renderView(ERR_500); } $session = new MessageFlash(); $session->setFlashMessage('Votre post a bien été supprimé !', 'alert alert-success'); diff --git a/src/Controller/SigninController.php b/src/Controller/SigninController.php index 60892d2..d93cf7a 100644 --- a/src/Controller/SigninController.php +++ b/src/Controller/SigninController.php @@ -31,8 +31,7 @@ public function signIn() $userManager = new UserManager(); $checkSignIn = new FormValidator(); if (!$checkSignIn->checkSignIn($user)) { - header('Location: /Blog/sign-in'); - exit(); + return header('Location: /Blog/sign-in'); } $session = new MessageFlash(); $session->setFlashMessage('Vous êtes bien connecté !', 'success'); diff --git a/src/Controller/SignupController.php b/src/Controller/SignupController.php index 8563aff..7fd7b50 100644 --- a/src/Controller/SignupController.php +++ b/src/Controller/SignupController.php @@ -36,8 +36,7 @@ public function signUp() $checkSignIn = new FormValidator(); if (!$checkSignIn->checkSignUp($user)) { - header('Location: /Blog/sign-up'); - exit(); + return header('Location: /Blog/sign-up'); } $session = new MessageFlash(); $session->setFlashMessage('Votre compte a bien été créé ! Vous pouvez maintenant vous connecter', 'success'); diff --git a/src/Services/AccessValidator.php b/src/Services/AccessValidator.php index d014748..dca8dd3 100644 --- a/src/Services/AccessValidator.php +++ b/src/Services/AccessValidator.php @@ -26,8 +26,7 @@ public function isValidAdmin(string $type = null): bool { if ($type != "Admin") { http_response_code(500); - $this->renderView('500.html.twig'); - exit(); + return $this->renderView('500.html.twig'); } return true; }