Skip to content

Commit

Permalink
0.8.149
Browse files Browse the repository at this point in the history
* fix redirect after login with newest webserver version
  • Loading branch information
lumapu committed Oct 1, 2024
1 parent 6815b7d commit eb8924a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 20 deletions.
1 change: 1 addition & 0 deletions src/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ platform = [email protected]
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 =
Expand Down
44 changes: 25 additions & 19 deletions src/web/web.h
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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;
}
}

Expand Down

0 comments on commit eb8924a

Please sign in to comment.