From 9d5bed5c1af4aca9cb37dbff3e111f51c67da451 Mon Sep 17 00:00:00 2001 From: Roman Bazalevskiy Date: Wed, 16 Nov 2022 21:42:39 +0300 Subject: [PATCH] =?utf8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD?= =?utf8?q?=D0=B0=20=D0=B0=D0=B2=D1=82=D0=BE=D1=80=D0=B8=D0=B7=D0=B0=D1=86?= =?utf8?q?=D0=B8=D1=8F=20=D0=B2=D0=B5=D0=B7=D0=B4=D0=B5,=20=D0=B3=D0=B4?= =?utf8?q?=D0=B5=20=D0=B5=D0=B5=20=D1=83=D0=BF=D1=83=D1=81=D1=82=D0=B8?= =?utf8?q?=D0=BB=20=D0=B4=D0=BE=20=D1=82=D0=BE=D0=B3=D0=BE.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- web.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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(); -- 2.34.1