Comments (4)
Nevermind... I see a problem with my code. It hides the value of the password but any time you re-save the Config without re-entering the custom password it updates your your custom password to "**********" as its hardcoded into the value. Need to put in a check to see if its ********** and ignore it if so. I also see you tried explaining that to me 🥴! Working on it now.
from esp-wifisettings.
from esp-wifisettings.
Thanks for the quick response Juerd.
I think I got it working. This is what I did.
In WiFiSettings.cpp I copied the "struct WiFiSettingsString" to a new "struct WiFiSettingsPasswordString" and manually entered, value = '**********' into h, and I also removed the h.replace("{value}", html_entities(value)); so it would not attempt to update the html value. So the WiFiSettingsPasswordString struct code added looks like this:
struct WiFiSettingsPasswordString : WiFiSettingsParameter {
virtual void set(const String& v) { value = v; }
String html() {
String h = F("<p><label>{label}:<br><input name='{name}' value='**********' placeholder='{init}' minlength={min}
maxlength={max}></label>");
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;
}
};
Then I copied "String WiFiSettingsClass::string..." to a new "WiFiSettingsClass::passwordstring..." and changed the struct references to the struct WiFiSettingsPasswordString, so the new class added looks like this:
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;
}
Editted as per below - I also changed the loop at line 410 to check if the value is "**********" so that it only stores it if it has been changed. The loop now looks like this:
for (auto& p : params) {
String pwstring = http.arg(p->name);
if (pwstring != "**********"){
p->set(http.arg(p->name));
if (! p->store()) ok = false;
}
}
Lastly in WiFiSettings.h I added:
String passwordstring(const String& name, const String& init = "", const String& label = "");
In my code where I declare the custom variable fields for the AP Config I declare String mqttpassword = WiFiSettings.passwordstring("MQTT Password");
and use the mqttpassword variable in other code to login to the mqtt server. It works and when I check the AP Configuration page it shows ********** in the mqttt password box now and the page source doesnt show the actual password value anywhere so I think it is working good and is secure.
from esp-wifisettings.
Now it works!
Changed the loop at line 410 in WiFiSettings.cpp to check if the value is "**********" before storing:
for (auto& p : params) {
String pwstring = http.arg(p->name);
if (pwstring != "**********"){
p->set(http.arg(p->name));
if (! p->store()) ok = false;
}
}
Updated the post above with this code. I'll probably change the password mask to ##**##**##**
in my final version for consistency with the wifi password.
from esp-wifisettings.
Related Issues (19)
- Warning in ESP8266 HOT 1
- Feature Request: Manual SSID HOT 3
- web interface HOT 4
- WiFiSettings.string() seems to encode the string in some way HOT 2
- WPS HOT 2
- MQTT client, PubSubClient HOT 1
- Compilation error with platform espressif8266 version 3.1.0 HOT 4
- Getting 255.255.255.255 as IP address HOT 4
- Didn't work with ESP32 C3 version HOT 12
- ESP32 does not connect unless restarted through portal HOT 2
- Drop down list on custom variables HOT 8
- Wifi AP hostname HOT 4
- Cannot connect to soft AP after .portal() is called HOT 7
- Compile error with expansion of macro 'F' HOT 4
- Make filesystem configurable
- WDT conflict with ESP32 support v3.x.x HOT 1
- SSID with apostrophe is truncated HOT 2
- arduino-esp32: Local IP is 255.255.255.255 after connection succeeds HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from esp-wifisettings.