From: Michael Friedrich Date: Wed, 9 May 2018 15:18:22 +0000 (+0200) Subject: Ensure that user input for groups is unique on API object creation X-Git-Tag: v2.9.0~62^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f070d2136a6ded1dbf08b0ba424f79eb6b29a8f8;p=icinga2 Ensure that user input for groups is unique on API object creation refs #4732 --- diff --git a/lib/remote/createobjecthandler.cpp b/lib/remote/createobjecthandler.cpp index e3646b3f3..a365ed664 100644 --- a/lib/remote/createobjecthandler.cpp +++ b/lib/remote/createobjecthandler.cpp @@ -71,6 +71,14 @@ bool CreateObjectHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& r } } + /* Sanity checks for unique groups array. */ + if (attrs->Contains("groups")) { + Array::Ptr groups = attrs->Get("groups"); + + if (groups) + attrs->Set("groups", groups->Unique()); + } + Dictionary::Ptr result1 = new Dictionary(); String status; Array::Ptr errors = new Array();