feature: добавил поле для ввода пароля входа в сеть ЦЗС

This commit is contained in:
2025-08-13 11:16:14 +03:00
parent beca00ff70
commit 7cd096a269
7 changed files with 88 additions and 11 deletions

View File

@@ -227,7 +227,7 @@ public:
resultJson["status"] = "ok";
resultJson["state"] = api->loadTerminalState();
} catch (std::exception& e) {
BOOST_LOG_TRIVIAL(error) << "WebHandle(/api/set/qos): Can't set QoS settings: " << e.what();
BOOST_LOG_TRIVIAL(error) << "WebHandle(/api/get/statistics): Can't get terminal state: " << e.what();
resultJson.clear();
resultJson["status"] = "error";
resultJson["error"] = e.what();
@@ -436,6 +436,36 @@ public:
auto result = resultJson.dump();
rep.content.insert(rep.content.end(), result.c_str(), result.c_str() + result.size());
}));
#ifdef MODEM_IS_TDMA
s.resources.emplace_back(std::make_unique<http::auth::AuthRequiredResource>("/api/set/cesPassword", this->auth, http::auth::User::EDIT_SETTINGS, [this](const http::server::Request& req, auto& rep) {
if (req.method != "POST") {
http::server::stockReply(http::server::bad_request, rep);
return;
}
rep.status = http::server::ok;
rep.headers.push_back({.name = "Content-Type", .value = toString(mime_types::json)});
nlohmann::json resultJson;
try {
auto reqJson = nlohmann::json::parse(std::string(req.payload.begin(), req.payload.end()));
auto password = reqJson["password"].get<std::string>();
this->api->executeInApi([&password](auto& cp) {
cp.setNetwork("ces_password", password);
});
resultJson["status"] = "ok";
} catch (std::exception& e) {
BOOST_LOG_TRIVIAL(error) << "WebHandle(/api/set/cesPassword): Can't set CES password: " << e.what();
resultJson.clear();
resultJson["status"] = "error";
resultJson["error"] = e.what();
}
auto result = resultJson.dump();
rep.content.insert(rep.content.end(), result.c_str(), result.c_str() + result.size());
}));
#endif
#endif
s.resources.emplace_back(std::make_unique<http::auth::AuthRequiredResource>("/api/reboot", this->auth, 0, [this](const auto& req, auto& rep) {