Skip to content
Snippets Groups Projects
Verified Commit 51d53f3f authored by Damien's avatar Damien
Browse files

FEAT #7721 Fix update label

parent 9d94e691
No related branches found
No related tags found
No related merge requests found
...@@ -105,7 +105,8 @@ class ContactGroupController ...@@ -105,7 +105,8 @@ class ContactGroupController
} }
$data = $request->getParams(); $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::stringType()->notEmpty()->validate($data['description']);
$check = $check && Validator::boolType()->validate($data['public']); $check = $check && Validator::boolType()->validate($data['public']);
if (!$check) { if (!$check) {
...@@ -113,7 +114,7 @@ class ContactGroupController ...@@ -113,7 +114,7 @@ class ContactGroupController
} }
$user = UserModel::getByUserId(['select' => ['id'], 'userId' => $GLOBALS['userId']]); $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)) { if (!empty($existingGroup)) {
return $response->withStatus(400)->withJson(['errors' => _CONTACTS_GROUP_LABEL_ALREADY_EXISTS]); return $response->withStatus(400)->withJson(['errors' => _CONTACTS_GROUP_LABEL_ALREADY_EXISTS]);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment