stephb9959
2022-11-24 11:50:27 -08:00
parent 34cef1ae0a
commit 07dc8617a4
3 changed files with 51 additions and 8 deletions

View File

@@ -55,6 +55,15 @@ namespace OpenWifi {
return BadRequest(RESTAPI::Errors::MissingOrInvalidParameters);
}
if(!SE.restricted.empty()) {
for(const auto &role:SE.restricted) {
if(SecurityObjects::UserTypeFromString(role)==SecurityObjects::UNKNOWN) {
return BadRequest(RESTAPI::Errors::InvalidUserRole);
}
}
std::sort(SE.restricted.begin(),SE.restricted.end());
}
if(!SE.uri.empty() && !Utils::ValidateURI(SE.uri)) {
return BadRequest(RESTAPI::Errors::InvalidURI);
}
@@ -85,6 +94,15 @@ namespace OpenWifi {
return BadRequest(RESTAPI::Errors::InvalidJSONDocument);
}
if(!SE.restricted.empty()) {
for(const auto &role:SE.restricted) {
if(SecurityObjects::UserTypeFromString(role)==SecurityObjects::UNKNOWN) {
return BadRequest(RESTAPI::Errors::InvalidUserRole);
}
}
std::sort(SE.restricted.begin(),SE.restricted.end());
}
GWObjects::ScriptEntry Existing;
if(!DB_.GetRecord("id", UUID, Existing)) {
return NotFound();
@@ -110,6 +128,10 @@ namespace OpenWifi {
return BadRequest(RESTAPI::Errors::InvalidURI);
}
if(ParsedBody_->has("restricted")) {
Existing.restricted = SE.restricted;
}
AssignIfPresent(ParsedBody_, "name", Existing.name);
AssignIfPresent(ParsedBody_, "description", Existing.description);
AssignIfPresent(ParsedBody_, "uri", Existing.uri);