mirror of
https://github.com/Telecominfraproject/wlan-cloud-owprov.git
synced 2025-11-02 11:37:54 +00:00
Fixing ConfigurationValidator to not crash.
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
#include "RESTObjects/RESTAPI_ProvObjects.h"
|
||||
#include "StorageService.h"
|
||||
#include "framework/RESTAPI_errors.h"
|
||||
#include "ConfigurationValidator.h"
|
||||
#include "framework/ConfigurationValidator.h"
|
||||
#include "RESTAPI/RESTAPI_db_helpers.h"
|
||||
|
||||
namespace OpenWifi{
|
||||
@@ -127,7 +127,7 @@ namespace OpenWifi{
|
||||
return BadRequest(RESTAPI::Errors::InvalidJSONDocument);
|
||||
}
|
||||
|
||||
if(C.info.name.empty()) {
|
||||
if(!ProvObjects::CreateObjectInfo(Obj,UserInfo_.userinfo,C.info)) {
|
||||
return BadRequest(RESTAPI::Errors::NameMustBeSet);
|
||||
}
|
||||
|
||||
@@ -135,11 +135,6 @@ namespace OpenWifi{
|
||||
return BadRequest(RESTAPI::Errors::UnknownId);
|
||||
}
|
||||
|
||||
C.info.modified = C.info.created = std::time(nullptr);
|
||||
C.info.id = MicroService::instance().CreateUUID();
|
||||
for(auto &i:C.info.notes)
|
||||
i.createdBy = UserInfo_.userinfo.email;
|
||||
|
||||
C.inUse.clear();
|
||||
if(C.deviceTypes.empty() || !StorageService()->AreAcceptableDeviceTypes(C.deviceTypes, true)) {
|
||||
return BadRequest(RESTAPI::Errors::InvalidDeviceTypes);
|
||||
@@ -175,6 +170,10 @@ namespace OpenWifi{
|
||||
return BadRequest(RESTAPI::Errors::InvalidJSONDocument);
|
||||
}
|
||||
|
||||
if(!UpdateObjectInfo(ParsedObj, UserInfo_.userinfo, Existing.info)) {
|
||||
return BadRequest(RESTAPI::Errors::NameMustBeSet);
|
||||
}
|
||||
|
||||
if(!NewConfig.deviceTypes.empty() && !StorageService()->AreAcceptableDeviceTypes(NewConfig.deviceTypes, true)) {
|
||||
return BadRequest(RESTAPI::Errors::InvalidDeviceTypes);
|
||||
}
|
||||
@@ -188,8 +187,6 @@ namespace OpenWifi{
|
||||
Existing.configuration = NewConfig.configuration;
|
||||
}
|
||||
|
||||
UpdateObjectInfo(ParsedObj, UserInfo_.userinfo, Existing.info);
|
||||
|
||||
std::string MovePolicy;
|
||||
bool MovingPolicy=false;
|
||||
if(AssignIfPresent(ParsedObj,"managementPolicy",MovePolicy)) {
|
||||
|
||||
Reference in New Issue
Block a user