@@ -27,16 +27,16 @@ void WebPortal::setup(Entry& mqttEntry, ConfigEntry& config, NTPClient& ntpClien
27
27
webServer->on (" /" , std::bind (&WebPortal::handleRoot, this ));
28
28
webServer->on (" /save" , std::bind (&WebPortal::handleSaveConfig, this ));
29
29
mqtt->each ([&](Entry* entry) {
30
- if (entry->isIn () || entry->isOut ()) {
30
+ if (entry->isIn () || entry->isOut ()) {
31
31
webServer->on (getRestPath (entry).c_str (), std::bind (&WebPortal::handleRest, this ));
32
- }
33
- });
32
+ }
33
+ });
34
34
webServer->onNotFound (std::bind (&WebPortal::handleNotFound, this ));
35
35
webServer->begin ();
36
36
}
37
37
38
38
void WebPortal::handleRoot () {
39
- if (!auth ()) return ;
39
+ if (!auth ()) return ;
40
40
webServer->send (200 , " text/html" , " " );
41
41
42
42
webServer->sendContent_P (HTML_MAIN1);
@@ -147,14 +147,14 @@ void WebPortal::handleRest() {
147
147
void WebPortal::handleSaveConfig () {
148
148
if (!auth ()) return ;
149
149
config->each ([&](Entry* entry) {
150
- String name = getName (entry);
151
- name = name.substring (9 );
152
- name.replace (" /" , " ." );
153
- entry->setValue (webServer->arg (name.c_str ()));
154
- Serial.print (name);
155
- Serial.print (" = " );
156
- Serial.println (webServer->arg (name.c_str ()));
157
- });
150
+ String name = getName (entry);
151
+ name = name.substring (9 );
152
+ name.replace (" /" , " ." );
153
+ entry->setValue (webServer->arg (name.c_str ()));
154
+ Serial.print (name);
155
+ Serial.print (" = " );
156
+ Serial.println (webServer->arg (name.c_str ()));
157
+ });
158
158
config->save ();
159
159
webServer->sendHeader (" Location" , String (" /" ), true );
160
160
webServer->send (302 , " text/plain" , " " );
@@ -191,11 +191,11 @@ String WebPortal::time(long time) {
191
191
}
192
192
193
193
bool WebPortal::auth () {
194
- char pass[32 ];
195
- config->getCString (" password" , " " , pass);
196
- if (strlen (pass) > 0 && !webServer->authenticate (" admin" , pass)) {
197
- webServer->requestAuthentication ();
198
- return false ;
199
- }
200
- return true ;
194
+ char pass[32 ];
195
+ config->getCString (" password" , " " , pass);
196
+ if (strlen (pass) > 0 && !webServer->authenticate (" admin" , pass)) {
197
+ webServer->requestAuthentication ();
198
+ return false ;
199
+ }
200
+ return true ;
201
201
}
0 commit comments