fix: add auth check on battery, huawei and powermeter API endpoints (#1155)
This commit is contained in:
parent
82b28e3732
commit
df11db1244
@ -145,15 +145,12 @@ void WebApiHuaweiClass::onPost(AsyncWebServerRequest* request)
|
|||||||
WebApi.sendJsonResponse(request, response, __FUNCTION__, __LINE__);
|
WebApi.sendJsonResponse(request, response, __FUNCTION__, __LINE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void WebApiHuaweiClass::onAdminGet(AsyncWebServerRequest* request)
|
void WebApiHuaweiClass::onAdminGet(AsyncWebServerRequest* request)
|
||||||
{
|
{
|
||||||
if (!WebApi.checkCredentialsReadonly(request)) {
|
if (!WebApi.checkCredentials(request)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
AsyncJsonResponse* response = new AsyncJsonResponse();
|
AsyncJsonResponse* response = new AsyncJsonResponse();
|
||||||
auto& root = response->getRoot();
|
auto& root = response->getRoot();
|
||||||
const CONFIG_T& config = Configuration.get();
|
const CONFIG_T& config = Configuration.get();
|
||||||
@ -167,7 +164,7 @@ void WebApiHuaweiClass::onAdminGet(AsyncWebServerRequest* request)
|
|||||||
root["voltage_limit"] = static_cast<int>(config.Huawei.Auto_Power_Voltage_Limit * 100) / 100.0;
|
root["voltage_limit"] = static_cast<int>(config.Huawei.Auto_Power_Voltage_Limit * 100) / 100.0;
|
||||||
root["enable_voltage_limit"] = static_cast<int>(config.Huawei.Auto_Power_Enable_Voltage_Limit * 100) / 100.0;
|
root["enable_voltage_limit"] = static_cast<int>(config.Huawei.Auto_Power_Enable_Voltage_Limit * 100) / 100.0;
|
||||||
root["lower_power_limit"] = config.Huawei.Auto_Power_Lower_Power_Limit;
|
root["lower_power_limit"] = config.Huawei.Auto_Power_Lower_Power_Limit;
|
||||||
root["upper_power_limit"] = config.Huawei.Auto_Power_Upper_Power_Limit;
|
root["upper_power_limit"] = config.Huawei.Auto_Power_Upper_Power_Limit;
|
||||||
root["stop_batterysoc_threshold"] = config.Huawei.Auto_Power_Stop_BatterySoC_Threshold;
|
root["stop_batterysoc_threshold"] = config.Huawei.Auto_Power_Stop_BatterySoC_Threshold;
|
||||||
root["target_power_consumption"] = config.Huawei.Auto_Power_Target_Power_Consumption;
|
root["target_power_consumption"] = config.Huawei.Auto_Power_Target_Power_Consumption;
|
||||||
|
|
||||||
@ -213,7 +210,7 @@ void WebApiHuaweiClass::onAdminPost(AsyncWebServerRequest* request)
|
|||||||
config.Huawei.Auto_Power_Voltage_Limit = root["voltage_limit"].as<float>();
|
config.Huawei.Auto_Power_Voltage_Limit = root["voltage_limit"].as<float>();
|
||||||
config.Huawei.Auto_Power_Enable_Voltage_Limit = root["enable_voltage_limit"].as<float>();
|
config.Huawei.Auto_Power_Enable_Voltage_Limit = root["enable_voltage_limit"].as<float>();
|
||||||
config.Huawei.Auto_Power_Lower_Power_Limit = root["lower_power_limit"].as<float>();
|
config.Huawei.Auto_Power_Lower_Power_Limit = root["lower_power_limit"].as<float>();
|
||||||
config.Huawei.Auto_Power_Upper_Power_Limit = root["upper_power_limit"].as<float>();
|
config.Huawei.Auto_Power_Upper_Power_Limit = root["upper_power_limit"].as<float>();
|
||||||
config.Huawei.Auto_Power_Stop_BatterySoC_Threshold = root["stop_batterysoc_threshold"];
|
config.Huawei.Auto_Power_Stop_BatterySoC_Threshold = root["stop_batterysoc_threshold"];
|
||||||
config.Huawei.Auto_Power_Target_Power_Consumption = root["target_power_consumption"];
|
config.Huawei.Auto_Power_Target_Power_Consumption = root["target_power_consumption"];
|
||||||
|
|
||||||
|
|||||||
@ -52,6 +52,10 @@ void WebApiBatteryClass::onStatus(AsyncWebServerRequest* request)
|
|||||||
|
|
||||||
void WebApiBatteryClass::onAdminGet(AsyncWebServerRequest* request)
|
void WebApiBatteryClass::onAdminGet(AsyncWebServerRequest* request)
|
||||||
{
|
{
|
||||||
|
if (!WebApi.checkCredentials(request)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
onStatus(request);
|
onStatus(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -32,6 +32,10 @@ void WebApiPowerMeterClass::init(AsyncWebServer& server, Scheduler& scheduler)
|
|||||||
|
|
||||||
void WebApiPowerMeterClass::onStatus(AsyncWebServerRequest* request)
|
void WebApiPowerMeterClass::onStatus(AsyncWebServerRequest* request)
|
||||||
{
|
{
|
||||||
|
if (!WebApi.checkCredentialsReadonly(request)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
AsyncJsonResponse* response = new AsyncJsonResponse();
|
AsyncJsonResponse* response = new AsyncJsonResponse();
|
||||||
auto& root = response->getRoot();
|
auto& root = response->getRoot();
|
||||||
const CONFIG_T& config = Configuration.get();
|
const CONFIG_T& config = Configuration.get();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user