From: Roman Bazalevskiy Date: Wed, 16 Nov 2022 18:42:39 +0000 (+0300) Subject: Добавлена авторизация везде, где ее упустил до того. X-Git-Url: https://git.rvb.name/esp-clock.git/commitdiff_plain/9d5bed5c1af4aca9cb37dbff3e111f51c67da451?ds=sidebyside;hp=--cc Добавлена авторизация везде, где ее упустил до того. --- 9d5bed5c1af4aca9cb37dbff3e111f51c67da451 diff --git a/web.cpp b/web.cpp index 7632250..b34d7cf 100644 --- a/web.cpp +++ b/web.cpp @@ -135,7 +135,6 @@ void setupWeb() { server.on("/action", HTTP_GET, [](AsyncWebServerRequest* request) { if (auth_user && auth_pwd && auth_user[0] && auth_pwd[0] && !request->authenticate(auth_user, auth_pwd)) { - Serial.print("Failed auth as user: "); Serial.print(auth_user); Serial.print(':'); Serial.print(auth_pwd); Serial.println('!'); return request-> requestAuthentication(); } if(request->hasParam("name")) { @@ -279,9 +278,9 @@ void setupWeb() { } }); - server.serveStatic("ui", LittleFS, "/ui.json"); + server.serveStatic("ui", LittleFS, "/ui.json").setAuthentication(auth_user,auth_pwd); - server.serveStatic("/", LittleFS, "/web/").setDefaultFile("index.html"); + server.serveStatic("/", LittleFS, "/web/").setDefaultFile("index.html").setAuthentication(auth_user,auth_pwd); server.onNotFound([](AsyncWebServerRequest *request){ request->send(404,"text/plain","Not found"); @@ -291,6 +290,8 @@ void setupWeb() { sendInitial(client); }); + events.setAuthentication(auth_user,auth_pwd); + server.addHandler(&events); server.begin();