diff --git a/src/CHANGES.md b/src/CHANGES.md index 36a9ee62..aef37af8 100644 --- a/src/CHANGES.md +++ b/src/CHANGES.md @@ -3,6 +3,7 @@ ## 0.8.149 - 2024-10-01 * fixed send power limit #1757 * merged: Fix minor typos #1758 +* fix redirect after login with newest webserver version ## 0.8.148 - 2024-09-30 * fixed send power limit #1757 diff --git a/src/platformio.ini b/src/platformio.ini index 2c0af1d7..d67d6091 100644 --- a/src/platformio.ini +++ b/src/platformio.ini @@ -154,7 +154,7 @@ platform = espressif32@6.7.0 board = lolin_d32 lib_deps = ${env.lib_deps} - https://github.com/mathieucarbou/ESPAsyncWebServer#v3.2.4 + https://github.com/mathieucarbou/ESPAsyncWebServer#v3.3.7 build_flags = ${env.build_flags} -DSPI_HAL monitor_filters = diff --git a/src/web/web.h b/src/web/web.h index 95ef7af1..efabe587 100644 --- a/src/web/web.h +++ b/src/web/web.h @@ -216,31 +216,36 @@ class Web { } private: - inline void checkRedirect(AsyncWebServerRequest *request) { - if ((mConfig->sys.protectionMask & PROT_MASK_INDEX) != PROT_MASK_INDEX) - request->redirect(F("/index")); - else if ((mConfig->sys.protectionMask & PROT_MASK_LIVE) != PROT_MASK_LIVE) - request->redirect(F("/live")); - else if ((mConfig->sys.protectionMask & PROT_MASK_HISTORY) != PROT_MASK_HISTORY) - request->redirect(F("/history")); - else if ((mConfig->sys.protectionMask & PROT_MASK_SERIAL) != PROT_MASK_SERIAL) - request->redirect(F("/serial")); - else if ((mConfig->sys.protectionMask & PROT_MASK_SYSTEM) != PROT_MASK_SYSTEM) - request->redirect(F("/system")); - else - request->redirect(F("/login")); - } - - void checkProtection(AsyncWebServerRequest *request) { + bool checkProtection(AsyncWebServerRequest *request) { if(mApp->isProtected(request->client()->remoteIP().toString().c_str(), "", true)) { - checkRedirect(request); - return; + if ((mConfig->sys.protectionMask & PROT_MASK_INDEX) != PROT_MASK_INDEX) { + request->redirect(F("/index")); + return true; + } else if ((mConfig->sys.protectionMask & PROT_MASK_LIVE) != PROT_MASK_LIVE) { + request->redirect(F("/live")); + return true; + } else if ((mConfig->sys.protectionMask & PROT_MASK_HISTORY) != PROT_MASK_HISTORY) { + request->redirect(F("/history")); + return true; + } else if ((mConfig->sys.protectionMask & PROT_MASK_SERIAL) != PROT_MASK_SERIAL) { + request->redirect(F("/serial")); + return true; + } else if ((mConfig->sys.protectionMask & PROT_MASK_SYSTEM) != PROT_MASK_SYSTEM) { + request->redirect(F("/system")); + return true; + } else { + request->redirect(F("/login")); + return true; + } } + + return false; } void getPage(AsyncWebServerRequest *request, uint16_t mask, const uint8_t *zippedHtml, uint32_t len) { if (CHECK_MASK(mConfig->sys.protectionMask, mask)) - checkProtection(request); + if(checkProtection(request)) + return; AsyncWebServerResponse *response = beginResponse(request, 200, F("text/html; charset=UTF-8"), zippedHtml, len); response->addHeader(F("Content-Encoding"), "gzip"); @@ -337,6 +342,7 @@ class Web { if (String(request->arg("pwd")) == String(mConfig->sys.adminPwd)) { mApp->unlock(request->client()->remoteIP().toString().c_str(), true); request->redirect("/index"); + return; } }