fixes #974 password placeholder

showPassword()  optional
This commit is contained in:
tablatronix
2019-11-29 18:32:10 -06:00
parent 56ad40d083
commit 72bcbd8a80
4 changed files with 28 additions and 4 deletions
+18
View File
@@ -974,6 +974,13 @@ void WiFiManager::handleWifi(boolean scan) {
pitem = FPSTR(HTTP_FORM_WIFI);
pitem.replace(FPSTR(T_v), WiFi_SSID());
if(_showPassword){
pitem.replace(FPSTR(T_p), WiFi_psk());
}
else {
pitem.replace(FPSTR(T_p),FPSTR(S_passph));
}
page += pitem;
page += getStaticOut();
@@ -2195,6 +2202,17 @@ void WiFiManager::setShowDnsFields(boolean alwaysShow){
_staShowDns = alwaysShow ? 1 : 0;
}
/**
* toggle showing password in wifi password field
* if not enabled, placeholder will be S_passph
* @since $dev
* @access public
* @param boolean alwaysShow [false]
*/
void WiFiManager::setShowPassword(boolean show){
_showPassword = show;
}
/**
* toggle captive portal
* if enabled, then devices that use captive portal checks will be redirected to root
+3
View File
@@ -239,6 +239,8 @@ class WiFiManager
void setShowStaticFields(boolean alwaysShow);
//if true, always show static dns, esle only show if set via setSTAStaticIPConfig
void setShowDnsFields(boolean alwaysShow);
// toggle showing the saved wifi password in wifi form, could be a security issue.
void setShowPassword(boolean show);
//if false, disable captive portal redirection
void setCaptivePortalEnable(boolean enabled);
//if false, timeout captive portal even if a STA client connected to softAP (false), suggest disabling if captiveportal is open
@@ -355,6 +357,7 @@ class WiFiManager
int _staShowStaticFields = 0; // ternary 1=always show static ip fields, 0=only if set, -1=never(cannot change ips via web!)
int _staShowDns = 0; // ternary 1=always show dns, 0=only if set, -1=never(cannot change dns via web!)
boolean _removeDuplicateAPs = true; // remove dup aps from wifiscan
boolean _showPassword = false; // show or hide saved password on wifi form, might be a security issue!
boolean _shouldBreakAfterConfig = false; // stop configportal on save failure
boolean _configPortalIsBlocking = true; // configportal enters blocking loop
boolean _enableCaptivePortal = true; // enable captive portal redirection
@@ -192,6 +192,9 @@ void setup() {
// set AP hidden
// wm.setAPHidden(true);
// show password publicly!
// wm.setShowPassword(true);
// set configrportal timeout
wm.setConfigPortalTimeout(120);
// wm.startConfigPortal("AutoConnectAP", "password");
@@ -202,7 +205,7 @@ void setup() {
//and goes into a blocking loop awaiting configuration
print_oled(F("Connecting..."),2);
if(!wm.autoConnect("AutoConnectAP")) {
if(!wm.autoConnect("WM_AutoConnectAP")) {
Serial.println("failed to connect and hit timeout");
print_oled("Not Connected",2);
}
@@ -211,7 +214,7 @@ void setup() {
Serial.println("TEST_CP ENABLED");
// start configportal always
wm.setConfigPortalTimeout(60);
wm.startConfigPortal();
wm.startConfigPortal("WM_ConnectAP");
}
else {
//if you get here you have connected to the WiFi
+2 -2
View File
@@ -47,7 +47,7 @@ const char HTTP_ITEM[] PROGMEM = "<div><a href='#p' onclick='c(this)
// const char HTTP_ITEM[] PROGMEM = "<div><a href='#p' onclick='c(this)'>{v}</a> {R} {r}% {q} {e}</div>"; // test all tokens
const char HTTP_FORM_START[] PROGMEM = "<form method='POST' action='{v}'>";
const char HTTP_FORM_WIFI[] PROGMEM = "<label for='s'>SSID</label><input id='s' name='s' maxlength='32' autocorrect='off' autocapitalize='none' placeholder='{v}'><br/><label for='p'>Password</label><input id='p' name='p' maxlength='64' type='password' placeholder=''>";
const char HTTP_FORM_WIFI[] PROGMEM = "<label for='s'>SSID</label><input id='s' name='s' maxlength='32' autocorrect='off' autocapitalize='none' placeholder='{v}'><br/><label for='p'>Password</label><input id='p' name='p' maxlength='64' type='password' placeholder='{p}'>";
const char HTTP_FORM_WIFI_END[] PROGMEM = "";
const char HTTP_FORM_STATIC_HEAD[] PROGMEM = "<hr><br/>";
const char HTTP_FORM_END[] PROGMEM = "<br/><br/><button type='submit'>Save</button></form>";
@@ -189,7 +189,7 @@ const char S_disable[] PROGMEM = "Disabled";
const char S_GET[] PROGMEM = "GET";
const char S_POST[] PROGMEM = "POST";
const char S_NA[] PROGMEM = "Unknown";
const char S_passph[] PROGMEM = "********";
const char S_titlewifisaved[] PROGMEM = "Credentials Saved";
const char S_titlewifi[] PROGMEM = "Config ESP";
const char S_titleinfo[] PROGMEM = "Info";