diff --git a/src/Application/Actions/Group/AddUserGroupAction.php b/src/Application/Actions/Group/AddUserGroupAction.php index 04155ee646c865f1c02a1fbfda4423a99693c10b..cff8adf5f3df9bda27e49a9118e54c7f28a1eec7 100755 --- a/src/Application/Actions/Group/AddUserGroupAction.php +++ b/src/Application/Actions/Group/AddUserGroupAction.php @@ -20,7 +20,13 @@ class AddUserGroupAction extends GroupAction if (!isset($group)) { throw new GroupNotFoundException(); } + $currentUser = $this->userRepository->find($_SESSION['userId']); + if ($this->group->hasUser($currentUser)){ + return $this->response + ->withHeader('Location', '/groups/' . $groupId) + ->withStatus(302); + } $currentUser->addGroup($group); $this->em->persist($group);