diff --git a/public/assets/css/general.css b/public/assets/css/general.css index 5480be2b939be0ebfa75d01807402853ceafaa33..1ab3e5e2b83d5cabd0324643431f801abd7943ea 100644 --- a/public/assets/css/general.css +++ b/public/assets/css/general.css @@ -95,7 +95,7 @@ body, html { } #list { - overflow:scroll; + overflow:scroll; grid-row:2/5; grid-column: 1/5; } diff --git a/src/Application/Actions/Group/AddUserGroupAction.php b/src/Application/Actions/Group/AddUserGroupAction.php index c278acddf7112740a479826029b2203ac9994429..1a7fe7b3254477cee9f8e1d7ec93449e266534bc 100755 --- a/src/Application/Actions/Group/AddUserGroupAction.php +++ b/src/Application/Actions/Group/AddUserGroupAction.php @@ -14,13 +14,21 @@ class AddUserGroupAction extends GroupAction */ protected function action(): Response { + if(!isset($_SESSION['userId'])){ + $this->flash->addMessage('login', 'Please log in or sign up.'); + + return $this->response + ->withHeader('Location', '/login') + ->withStatus(302); + } + $groupId = (int) $this->resolveArg('id'); $group = $this->groupRepository->find($groupId); if (!isset($group)) { throw new GroupNotFoundException(); } - + $currentUser = $this->userRepository->find($_SESSION['userId']); if ($group->hasUser($_SESSION['userId'])){ return $this->response diff --git a/src/Application/Actions/Group/CreateGroupAction.php b/src/Application/Actions/Group/CreateGroupAction.php index c43bcbdba79f2d8f8ad2b3780103b61cd1bfb825..058a3cd2f40ce7e349f20013bf78adef9de9b484 100755 --- a/src/Application/Actions/Group/CreateGroupAction.php +++ b/src/Application/Actions/Group/CreateGroupAction.php @@ -15,8 +15,16 @@ class CreateGroupAction extends GroupAction protected function action(): Response { $parsedRequestBody = (array)$this->request->getParsedBody(); - $currentUser = $this->em->getRepository('App\Domain\User\User')->find($_SESSION['userId']); + if(!isset($_SESSION['userId'])){ + $this->flash->addMessage('login', 'Please log in or sign up.'); + + return $this->response + ->withHeader('Location', '/login') + ->withStatus(302); + } + + $currentUser = $this->em->getRepository('App\Domain\User\User')->find($_SESSION['userId']); $groupname = $parsedRequestBody['name']; $description = $parsedRequestBody['description']; $private = isset($parsedRequestBody['private']) ? 1 : 0; diff --git a/src/Application/Actions/Group/DeleteGroupAction.php b/src/Application/Actions/Group/DeleteGroupAction.php index ef6ccdd6dcbbfd3ea8bf2c03cd62ff7a8339aac2..e080aa20b08cf5d6e527c29c67917995d2180954 100755 --- a/src/Application/Actions/Group/DeleteGroupAction.php +++ b/src/Application/Actions/Group/DeleteGroupAction.php @@ -14,6 +14,14 @@ class DeleteGroupAction extends GroupAction */ protected function action(): Response { + if(!isset($_SESSION['userId'])){ + $this->flash->addMessage('login', 'Please log in or sign up.'); + + return $this->response + ->withHeader('Location', '/login') + ->withStatus(302); + } + $groupId = (int) $this->resolveArg('id'); $group = $this->groupRepository->find($groupId); diff --git a/src/Application/Actions/Group/ListGroupsAction.php b/src/Application/Actions/Group/ListGroupsAction.php index 670829214eb11eadf0f8d2059fcfc5d0f93da10c..7ed27ea3ef13047488176358a73a572b206a60d2 100755 --- a/src/Application/Actions/Group/ListGroupsAction.php +++ b/src/Application/Actions/Group/ListGroupsAction.php @@ -12,12 +12,16 @@ class ListGroupsAction extends GroupAction */ protected function action(): Response { + $query = $this->em->createQueryBuilder(); $query->select('g') - ->from('App\Domain\Group\Group', 'g') - ->where('g.private = 0') - ->orWhere(':user_id MEMBER OF g.users') + ->from('App\Domain\Group\Group', 'g') + ->where('g.private = 0'); + + if(isset($_SESSION['userId'])){ + $query->orWhere(':user_id MEMBER OF g.users') ->setParameters(array(':user_id' => $_SESSION['userId'])); + } $groups = $query->getQuery()->getResult(); diff --git a/src/Application/Actions/Group/ViewModifyGroupForm.php b/src/Application/Actions/Group/ViewModifyGroupForm.php index 9136da7716b76377f6bd4f208a723e87c3868153..e961c8375faaacdeb40a27f98c80284c172209ea 100644 --- a/src/Application/Actions/Group/ViewModifyGroupForm.php +++ b/src/Application/Actions/Group/ViewModifyGroupForm.php @@ -12,7 +12,15 @@ class ViewModifyGroupForm extends GroupAction * {@inheritdoc} */ protected function action(): Response - { + { + if(!isset($_SESSION['userId'])){ + $this->flash->addMessage('login', 'Please log in or sign up.'); + + return $this->response + ->withHeader('Location', '/login') + ->withStatus(302); + } + $parsedRequestBody = (array)$this->request->getParsedBody(); $groupId = (int) $this->resolveArg('id'); diff --git a/src/Application/Actions/User/LogInUserAction.php b/src/Application/Actions/User/LogInUserAction.php index 63e2e73e4143e65cf5bef4f3a79ab191c5035888..69a1c05ac718ec55779b53307fdb69f3036d4840 100644 --- a/src/Application/Actions/User/LogInUserAction.php +++ b/src/Application/Actions/User/LogInUserAction.php @@ -20,7 +20,11 @@ class LogInUserAction extends UserAction $user = $this->userRepository->findOneBy(array('username' => $username)); if (!isset($user)) { - throw new UserNotFoundException(); + $this->flash->addMessage('signup', 'Please sign up.'); + + return $this->response + ->withHeader('Location', '/signup') + ->withStatus(302); } if (!password_verify($password, $user->getPassword())) {