From 62952199ef62ad798cdd161cde564871ad8c7791 Mon Sep 17 00:00:00 2001 From: Valdez <120133974+ValdezNC@users.noreply.github.com> Date: Sat, 6 Jan 2024 21:58:04 -0800 Subject: [PATCH 1/2] Update WiFiSettings.cpp --- WiFiSettings.cpp | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/WiFiSettings.cpp b/WiFiSettings.cpp index 4314d36..c8fe388 100644 --- a/WiFiSettings.cpp +++ b/WiFiSettings.cpp @@ -100,6 +100,19 @@ namespace { // Helpers } }; + struct WiFiSettingsPasswordString : WiFiSettingsParameter { + virtual void set(const String& v) { value = v; } + String html() { + String h = F("

"); + h.replace("{name}", html_entities(name)); + h.replace("{init}", html_entities(init)); + h.replace("{label}", html_entities(label)); + h.replace("{min}", String(min)); + h.replace("{max}", String(max)); + return h; + } + }; + struct WiFiSettingsInt : WiFiSettingsParameter { virtual void set(const String& v) { value = v; } String html() { @@ -174,6 +187,18 @@ String WiFiSettingsClass::string(const String& name, unsigned int min_length, un return rv; } +String WiFiSettingsClass::passwordstring(const String& name, const String& init, const String& label) { + begin(); + struct WiFiSettingsPasswordString* x = new WiFiSettingsPasswordString(); + x->name = name; + x->label = label.length() ? label : name; + x->init = init; + x->fill(); + + params.push_back(x); + return x->value.length() ? x->value : x->init; +} + long WiFiSettingsClass::integer(const String& name, long init, const String& label) { begin(); struct WiFiSettingsInt* x = new WiFiSettingsInt(); @@ -408,8 +433,11 @@ void WiFiSettingsClass::portal() { } for (auto& p : params) { - p->set(http.arg(p->name)); - if (! p->store()) ok = false; + String pwstring = http.arg(p->name); + if (pwstring != "##**##**##**"){ + p->set(http.arg(p->name)); + if (! p->store()) ok = false; + } } if (ok) { From 2a07607fded0d453ca30a90b73d44704168c8d4d Mon Sep 17 00:00:00 2001 From: Valdez <120133974+ValdezNC@users.noreply.github.com> Date: Sat, 6 Jan 2024 21:58:57 -0800 Subject: [PATCH 2/2] Update WiFiSettings.h --- WiFiSettings.h | 1 + 1 file changed, 1 insertion(+) diff --git a/WiFiSettings.h b/WiFiSettings.h index e284a14..62a8658 100644 --- a/WiFiSettings.h +++ b/WiFiSettings.h @@ -17,6 +17,7 @@ class WiFiSettingsClass { String string(const String& name, const String& init = "", const String& label = ""); String string(const String& name, unsigned int max_length, const String& init = "", const String& label = ""); String string(const String& name, unsigned int min_length, unsigned int max_length, const String& init = "", const String& label = ""); + String passwordstring(const String& name, const String& init = "", const String& label = ""); long integer(const String& name, long init = 0, const String& label = ""); long integer(const String& name, long min, long max, long init = 0, const String& label = ""); bool checkbox(const String& name, bool init = false, const String& label = "");