diff --git a/src/Application/Actions/Group/AddUsersGroupAction.php b/src/Application/Actions/Group/AddUsersGroupAction.php index e970da821bb79de2602b92dc23bd5807d177ab36..2d1905ebcbce6eea178f4776be1f929d8d840ac5 100755 --- a/src/Application/Actions/Group/AddUsersGroupAction.php +++ b/src/Application/Actions/Group/AddUsersGroupAction.php @@ -14,23 +14,29 @@ class AddUsersGroupAction extends GroupAction */ protected function action(): Response { + $parsedRequestBody = (array)$this->request->getParsedBody(); $groupId = (int) $this->resolveArg('id'); - $group = $this->groupRepository->find($groupId); + if (!isset($parsedRequestBody['ids'])) + { + return $this->response + ->withHeader('Location', '/groups/' . $groupId) + ->withStatus(302); + } - $parsedRequestBody = (array)$this->request->getParsedBody(); + $group = $this->groupRepository->find($groupId); $user_ids = $parsedRequestBody['ids']; if (!isset($group)) { throw new GroupNotFoundException(); } - + $users_query = $this->userRepository->createQueryBuilder('u'); $users_list = $users_query ->where('u.id IN (:user_ids)') ->setParameter('user_ids', $user_ids) ->getQuery() ->getResult(); - + foreach ($users_list as $user) { if (!$group->hasUser($user->getId())) { $user->addGroup($group); diff --git a/src/Application/Actions/Group/CreateGroupAction.php b/src/Application/Actions/Group/CreateGroupAction.php index bd86d84d2728a777ebc2a972cba4ce2260e03290..ea94e8672e4c232bb315516c6c5e522295519139 100755 --- a/src/Application/Actions/Group/CreateGroupAction.php +++ b/src/Application/Actions/Group/CreateGroupAction.php @@ -50,7 +50,7 @@ class CreateGroupAction extends GroupAction $this->logger->info("Group has been created."); return $this->response - ->withHeader('Location', '/groups' . $groupId) + ->withHeader('Location', '/groups' . $group->getId()) ->withStatus(302); } diff --git a/src/Application/Actions/User/AccountAction.php b/src/Application/Actions/User/AccountAction.php index b6084b26a6c83833bd8512533129000e883a6e83..bb1f559b28690d4a0f85a2b0ca41a9d1a5a15169 100755 --- a/src/Application/Actions/User/AccountAction.php +++ b/src/Application/Actions/User/AccountAction.php @@ -19,7 +19,7 @@ class AccountAction extends UserAction ->withHeader('Location', '/login') ->withStatus(302); } - + $user = $this->userRepository->find($_SESSION['userId']); if (!isset($user)) {