sec: dane wifi nie pobierane przez endpoint do konfiguracji
This commit is contained in:
+10
-14
@@ -1055,22 +1055,18 @@ void setupHttpServer()
|
||||
saveConfig();
|
||||
req->send(200, "application/json", "{\"ok\":true}"); });
|
||||
|
||||
// GET /config.json — gesture config only (WiFi credentials are NEVER exposed)
|
||||
// GET /config.json — gesture config only, built from RAM (WiFi NEVER exposed)
|
||||
httpServer.on("/config.json", HTTP_GET, [](AsyncWebServerRequest *req) {
|
||||
if (!LittleFS.begin(false)) {
|
||||
req->send(500, "application/json", "{\"error\":\"LittleFS unavailable\"}");
|
||||
return;
|
||||
JsonDocument doc;
|
||||
for (uint8_t i = 0; i < NUM_GESTURES; i++) {
|
||||
doc[GNAME[i]]["url"] = gConfig[i].url;
|
||||
doc[GNAME[i]]["mood"] = gConfig[i].mood;
|
||||
doc[GNAME[i]]["action"] = gConfig[i].action;
|
||||
doc[GNAME[i]]["enabled"] = gConfig[i].enabled;
|
||||
}
|
||||
File f = LittleFS.open("/config.json", "r");
|
||||
if (!f) {
|
||||
LittleFS.end();
|
||||
req->send(404, "application/json", "{\"error\":\"not found\"}");
|
||||
return;
|
||||
}
|
||||
String body = f.readString();
|
||||
f.close();
|
||||
LittleFS.end();
|
||||
req->send(200, "application/json", body);
|
||||
String out;
|
||||
serializeJsonPretty(doc, out);
|
||||
req->send(200, "application/json", out);
|
||||
});
|
||||
|
||||
httpServer.begin();
|
||||
|
||||
Reference in New Issue
Block a user