From 9fd26fa574beefa8bcc2b21325c2f57a715fe529 Mon Sep 17 00:00:00 2001
From: Blaz Kristan
Date: Tue, 1 Mar 2022 23:37:28 +0100
Subject: [PATCH 1/4] Settings PIN protection.
---
tools/cdata.js | 6 +
wled00/cfg.cpp | 5 +
wled00/data/msg.htm | 26 +-
wled00/data/settings_pin.htm | 31 +
wled00/data/settings_sec.htm | 9 +-
wled00/fcn_declare.h | 1 +
wled00/html_other.h | 4 +-
wled00/html_settings.h | 269 +++++---
wled00/set.cpp | 22 +-
wled00/wled.cpp | 10 +-
wled00/wled.h | 13 +-
wled00/wled_server.cpp | 108 +--
wled00/xml.cpp | 1265 +++++++++++++++++-----------------
13 files changed, 954 insertions(+), 815 deletions(-)
create mode 100644 wled00/data/settings_pin.htm
diff --git a/tools/cdata.js b/tools/cdata.js
index 71fafdcb..5c9e74df 100644
--- a/tools/cdata.js
+++ b/tools/cdata.js
@@ -365,6 +365,12 @@ writeChunks(
/function GetV().*\<\/script\>/gms,
""
)
+ },
+ {
+ file: "settings_pin.htm",
+ name: "PAGE_settings_pin",
+ method: "gzip",
+ filter: "html-minify"
}
],
"wled00/html_settings.h"
diff --git a/wled00/cfg.cpp b/wled00/cfg.cpp
index 8ca08d81..c2dbe91f 100644
--- a/wled00/cfg.cpp
+++ b/wled00/cfg.cpp
@@ -864,6 +864,9 @@ bool deserializeConfigSec() {
getStringFromJson(hueApiKey, interfaces["hue"][F("key")], 47);
#endif
+ getStringFromJson(settingsPIN, doc["pin"], 5);
+ correctPIN = !strlen(settingsPIN);
+
JsonObject ota = doc["ota"];
getStringFromJson(otaPass, ota[F("pwd")], 33);
CJSON(otaLock, ota[F("lock")]);
@@ -903,6 +906,8 @@ void serializeConfigSec() {
if_hue[F("key")] = hueApiKey;
#endif
+ doc["pin"] = settingsPIN;
+
JsonObject ota = doc.createNestedObject("ota");
ota[F("pwd")] = otaPass;
ota[F("lock")] = otaLock;
diff --git a/wled00/data/msg.htm b/wled00/data/msg.htm
index e25aeda0..bb598338 100644
--- a/wled00/data/msg.htm
+++ b/wled00/data/msg.htm
@@ -4,27 +4,13 @@
WLED Message
-
+
diff --git a/wled00/data/settings_pin.htm b/wled00/data/settings_pin.htm
new file mode 100644
index 00000000..7faf2467
--- /dev/null
+++ b/wled00/data/settings_pin.htm
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+ Misc Settings
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/wled00/data/settings_sec.htm b/wled00/data/settings_sec.htm
index 2c07389f..42fa8910 100644
--- a/wled00/data/settings_sec.htm
+++ b/wled00/data/settings_sec.htm
@@ -60,9 +60,10 @@
%MSG%
diff --git a/wled00/fcn_declare.h b/wled00/fcn_declare.h
index 26ba161c..f3004bf0 100644
--- a/wled00/fcn_declare.h
+++ b/wled00/fcn_declare.h
@@ -320,6 +320,7 @@ void updateBaudRate(uint32_t rate);
//wled_server.cpp
bool isIp(String str);
+void createEditHandler(bool enable);
bool captivePortal(AsyncWebServerRequest *request);
void initServer();
void serveIndexOrWelcome(AsyncWebServerRequest *request);
diff --git a/wled00/html_other.h b/wled00/html_other.h
index acc1458d..406335d5 100644
--- a/wled00/html_other.h
+++ b/wled00/html_other.h
@@ -21,9 +21,7 @@ const uint8_t PAGE_usermod[] PROGMEM = {
const char PAGE_msg[] PROGMEM = R"=====(