diff --git a/src/app/contact/controllers/ContactGroupController.php b/src/app/contact/controllers/ContactGroupController.php index a633899810a30689053d39fbd0eac68166c584cf..9a5f2f9aa535257e2abeb8f64d6ff75d4717d190 100644 --- a/src/app/contact/controllers/ContactGroupController.php +++ b/src/app/contact/controllers/ContactGroupController.php @@ -105,7 +105,8 @@ class ContactGroupController } $data = $request->getParams(); - $check = Validator::stringType()->notEmpty()->validate($data['label']); + $check = Validator::intVal()->notEmpty()->validate($data['id']); + $check = $check && Validator::stringType()->notEmpty()->validate($data['label']); $check = $check && Validator::stringType()->notEmpty()->validate($data['description']); $check = $check && Validator::boolType()->validate($data['public']); if (!$check) { @@ -113,7 +114,7 @@ class ContactGroupController } $user = UserModel::getByUserId(['select' => ['id'], 'userId' => $GLOBALS['userId']]); - $existingGroup = ContactGroupModel::get(['select' => [1], 'where' => ['label = ?', 'owner = ?'], 'data' => [$data['label'], $user['id']]]); + $existingGroup = ContactGroupModel::get(['select' => [1], 'where' => ['label = ?', 'owner = ?', 'id != ?'], 'data' => [$data['label'], $user['id'], $data['id']]]); if (!empty($existingGroup)) { return $response->withStatus(400)->withJson(['errors' => _CONTACTS_GROUP_LABEL_ALREADY_EXISTS]); }