From b758841badf25c029862c512bdbb61924372dfc5 Mon Sep 17 00:00:00 2001 From: Moreau Elise <moreau.elise13@gmail.com> Date: Sat, 31 Oct 2020 15:31:54 +0100 Subject: [PATCH] add messages and redirection if current user not logged --- src/Application/Actions/Group/AddUserGroupAction.php | 2 +- src/Application/Actions/Group/CreateGroupAction.php | 2 +- src/Application/Actions/Group/DeleteGroupAction.php | 6 +++--- src/Application/Actions/Group/ViewModifyGroupForm.php | 2 +- src/Application/Actions/User/CreateUserAction.php | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Application/Actions/Group/AddUserGroupAction.php b/src/Application/Actions/Group/AddUserGroupAction.php index ee30f0e..9a37f61 100755 --- a/src/Application/Actions/Group/AddUserGroupAction.php +++ b/src/Application/Actions/Group/AddUserGroupAction.php @@ -15,7 +15,7 @@ class AddUserGroupAction extends GroupAction protected function action(): Response { if(!isset($_SESSION['userId'])){ - $this->flash->addMessage('login', 'Please log in or sign up.'); + $this->flash->addMessage('message', 'Please log in or sign up.'); return $this->response ->withHeader('Location', '/login') diff --git a/src/Application/Actions/Group/CreateGroupAction.php b/src/Application/Actions/Group/CreateGroupAction.php index ea94e86..7d2b69a 100755 --- a/src/Application/Actions/Group/CreateGroupAction.php +++ b/src/Application/Actions/Group/CreateGroupAction.php @@ -17,7 +17,7 @@ class CreateGroupAction extends GroupAction $parsedRequestBody = (array)$this->request->getParsedBody(); if(!isset($_SESSION['userId'])){ - $this->flash->addMessage('login', 'Please log in or sign up.'); + $this->flash->addMessage('message', 'Please log in or sign up.'); return $this->response ->withHeader('Location', '/login') diff --git a/src/Application/Actions/Group/DeleteGroupAction.php b/src/Application/Actions/Group/DeleteGroupAction.php index e080aa2..f0c91a4 100755 --- a/src/Application/Actions/Group/DeleteGroupAction.php +++ b/src/Application/Actions/Group/DeleteGroupAction.php @@ -15,13 +15,13 @@ class DeleteGroupAction extends GroupAction protected function action(): Response { if(!isset($_SESSION['userId'])){ - $this->flash->addMessage('login', 'Please log in or sign up.'); + $this->flash->addMessage('message', 'Please log in or sign up.'); return $this->response ->withHeader('Location', '/login') ->withStatus(302); } - + $groupId = (int) $this->resolveArg('id'); $group = $this->groupRepository->find($groupId); @@ -34,7 +34,7 @@ class DeleteGroupAction extends GroupAction ->withHeader('Location', '/account') ->withStatus(302); } - + $this->em->remove($group); $this->em->flush(); diff --git a/src/Application/Actions/Group/ViewModifyGroupForm.php b/src/Application/Actions/Group/ViewModifyGroupForm.php index 1ff41cb..509d42c 100644 --- a/src/Application/Actions/Group/ViewModifyGroupForm.php +++ b/src/Application/Actions/Group/ViewModifyGroupForm.php @@ -14,7 +14,7 @@ class ViewModifyGroupForm extends GroupAction protected function action(): Response { if(!isset($_SESSION['userId'])){ - $this->flash->addMessage('login', 'Please log in or sign up.'); + $this->flash->addMessage('message', 'Please log in or sign up.'); return $this->response ->withHeader('Location', '/login') diff --git a/src/Application/Actions/User/CreateUserAction.php b/src/Application/Actions/User/CreateUserAction.php index 076e3a7..0f71786 100755 --- a/src/Application/Actions/User/CreateUserAction.php +++ b/src/Application/Actions/User/CreateUserAction.php @@ -89,7 +89,7 @@ class CreateUserAction extends UserAction $this->logger->info("User has been created."); - $this->flash->addMessage('creation', 'Your account has been created. Please log in.'); + $this->flash->addMessage('message', 'Your account has been created. Please log in.'); return $this->response ->withHeader('Location', '/login') ->withStatus(302); -- GitLab