fixes
This commit is contained in:
@ -7,11 +7,11 @@ from Cheetah.Template import Template
|
||||
|
||||
configItems = [
|
||||
{"label":"_", "key":"magic", "type":"I", "default": ""},
|
||||
{"label":"Config Username", "key":"confUser", "type":"C", "length":32, "default":"admin"},
|
||||
{"label":"Config Password", "key":"confPasswd", "type":"C", "length":32, "default":"geheim123"},
|
||||
{"label":"Config Username", "key":"confUser", "type":"C", "length":16, "default":"admin"},
|
||||
{"label":"Config Password", "key":"confPasswd", "type":"C", "length":16, "default":"geheim123"},
|
||||
{"label":"Wifi SSID", "key":"wifiSsid", "type":"C", "length":32, "default":"test"},
|
||||
{"label":"Wifi Key", "key":"wifiKey", "type":"C", "length":64, "default":"geheim"},
|
||||
{"label":"MQTT Broker", "key":"mqttBroker", "type":"C", "length":64, "default":"broker.hottis.de"},
|
||||
{"label":"MQTT Broker", "key":"mqttBroker", "type":"C", "length":32, "default":"broker.hottis.de"},
|
||||
{"label":"MQTT Username", "key":"mqttUser", "type":"C", "length":32, "default":"TouchSwitch"},
|
||||
{"label":"MQTT Password", "key":"mqttPass", "type":"C", "length":32, "default":"geheim123"},
|
||||
{"label":"MQTT ClientId", "key":"mqttClientId", "type":"C", "length":32, "default":"TouchSwitch"},
|
||||
@ -26,7 +26,7 @@ configItems = [
|
||||
]
|
||||
|
||||
|
||||
magic = 0xC0DE0002
|
||||
magic = 0xC0DE0003
|
||||
appName = "ESP8266 based TouchSwitch"
|
||||
confWifiSsid = "espconfig"
|
||||
|
||||
|
@ -19,18 +19,16 @@ bool configSaved = false;
|
||||
|
||||
|
||||
static bool checkAuthentication() {
|
||||
Serial.print("User: "); Serial.println(configBlock.confUser);
|
||||
Serial.print("Pass: "); Serial.println(configBlock.confPasswd);
|
||||
return webServer.authenticate(configBlock.confUser, configBlock.confPasswd);
|
||||
}
|
||||
|
||||
void configServeIndex() {
|
||||
if (! checkAuthentication()) {
|
||||
return webServer.requestAuthentication();
|
||||
}
|
||||
|
||||
|
||||
bool configValid = (configBlock.magic == MAGIC);
|
||||
|
||||
if (! configValid) {
|
||||
configBlock.magic = MAGIC;
|
||||
#for $configItem in $configItems
|
||||
#if $configItem.label != "_"
|
||||
#if $configItem.type == "C"
|
||||
@ -41,7 +39,12 @@ void configServeIndex() {
|
||||
#end if
|
||||
#end for
|
||||
}
|
||||
|
||||
|
||||
if (! checkAuthentication()) {
|
||||
return webServer.requestAuthentication();
|
||||
}
|
||||
|
||||
|
||||
String buffer =
|
||||
"<!doctype html"
|
||||
"<html lang=\"en\">"
|
||||
|
Reference in New Issue
Block a user