diff --git a/arangod/RestHandler/RestUsersHandler.cpp b/arangod/RestHandler/RestUsersHandler.cpp index c619e17210..dd3146af59 100644 --- a/arangod/RestHandler/RestUsersHandler.cpp +++ b/arangod/RestHandler/RestUsersHandler.cpp @@ -346,12 +346,31 @@ RestStatus RestUsersHandler::putRequest(AuthInfo* authInfo) { if (canAccessUser(user)) { std::string const& key = suffixes[2]; VPackBuilder conf = authInfo->getConfigData(user); + // The API expects: { value : } + // If we get sth else than the above it is translated + // to a remove of the config option. if (!parsedBody->isEmpty()) { - VPackBuilder b; - b(VPackValue(VPackValueType::Object))(key, parsedBody->slice())(); - conf = conf.slice().isObject() - ? VPackCollection::merge(conf.slice(), b.slice(), false) - : b; + VPackSlice newVal = parsedBody->slice(); + VPackSlice oldConf = conf.slice(); + if (!newVal.isObject() || !newVal.hasKey("value")) { + if (!oldConf.isObject() || !oldConf.hasKey(key)) { + // Nothing to do. We do not have a config yet. + // so we do not create a new empty one. + resetResponse(ResponseCode::OK); + return RestStatus::DONE; + } + conf = VPackCollection::remove(oldConf, std::unordered_set{key}); + } else { + // We need to merge the new key into the config + newVal = newVal.get("value"); + VPackBuilder b; + b.openObject(); + b.add(key, newVal); + b.close(); + conf = oldConf.isObject() + ? VPackCollection::merge(oldConf, b.slice(), false) + : b; + } } Result r = authInfo->setConfigData(user, conf.slice());