stephb9959
2023-10-03 21:52:56 -07:00
parent 7dd33ca841
commit 69e507a5bd
10 changed files with 120 additions and 50 deletions

View File

@@ -3,10 +3,20 @@
//
#include "RESTAPI_radiusendpoint_list_handler.h"
#include "framework/AppServiceRegistry.h"
#include "RadiusEndpointUpdater.h"
namespace OpenWifi {
void RESTAPI_radiusendpoint_list_handler::DoGet() {
if(GetBoolParameter("lastUpdate")) {
uint64_t LastUpdate=0;
AppServiceRegistry().Get("radiusEndpointLastUpdate", LastUpdate);
Poco::JSON::Object Answer;
Answer.set("lastUpdate",LastUpdate);
return ReturnObject(Answer);
}
if(QB_.CountOnly) {
return ReturnCountOnly(DB_.Count());
}
@@ -15,4 +25,25 @@ namespace OpenWifi {
return ReturnObject(Records);
}
void RESTAPI_radiusendpoint_list_handler::DoPut() {
if( UserInfo_.userinfo.userRole!=SecurityObjects::ROOT &&
UserInfo_.userinfo.userRole!=SecurityObjects::ADMIN) {
return BadRequest(RESTAPI::Errors::ACCESS_DENIED);
}
if(GetBoolParameter("updateEndpoints")) {
RadiusEndpointUpdater R;
std::string Error;
uint64_t ErrorNum = 0;
R.UpdateEndpoints(Error, ErrorNum);
Poco::JSON::Object Answer;
Answer.set("Error", Error);
Answer.set("ErrorNum", ErrorNum);
return ReturnObject(Answer);
}
return BadRequest(RESTAPI::Errors::MissingAuthenticationInformation);
}
} // OpenWifi