Added an authentication define to SmartSwitch.ino to be able to activate on all static pages.

Same credentials as the /edit
This commit is contained in:
lorol
2020-03-12 10:32:06 -04:00
parent 7d648b45a2
commit cda9ae65c8
2 changed files with 11 additions and 7 deletions

View File

@@ -1,11 +1,11 @@
![](SCREENSHOT.PNG) ![](AWIFIMAN.JPG)
![](AWIFIMAN.JPG) ![](SCREENSHOT.PNG)
## SmartSwitch
* Based on ESP_AsyncFSBrowser
* Temperature Control for heater with schedule for car block heater or battery charger
* Remote Temperature Control application with schedule (example car block heater or battery charger)
* Based on the ESP_AsyncFSBrowser example
* Wide browser compatibility, no extra server-side needed.
* HTTP server and WebSocket, single port
* Standalone, no JS dependencies for the browser from Internet (I hope)
* Standalone, no JS dependencies for the browser from Internet (I hope), ace editor included
* Added ESPAsyncWiFiManager
* Real Time (NTP) w/ Time Zones
* Memorized settings to EEPROM

View File

@@ -13,7 +13,8 @@ Multiple clients can be connected at same time, they see each other requests
Use latest ESP core lib (from github)
*/
#define USE_WFM // to use ESPAsyncWiFiManager
#define USE_WFM // to use ESPAsyncWiFiManager
#define USE_AUTH // .setAuthentication for all static
#include <ArduinoOTA.h>
#ifdef ESP32
@@ -449,8 +450,11 @@ void setup(){
request->send(200, "text/plain","Erasing WiFi data ...");
});
server.serveStatic("/", SPIFFS, "/").setDefaultFile("index.htm"); //.setAuthentication(http_username,http_password); //append or remove auth part
#ifdef USE_AUTH
server.serveStatic("/", SPIFFS, "/").setDefaultFile("index.htm").setAuthentication(http_username,http_password);
#else
server.serveStatic("/", SPIFFS, "/").setDefaultFile("index.htm");
#endif
server.onNotFound([](AsyncWebServerRequest *request){ // nothing known
Serial.print(F("NOT_FOUND: "));