mirror of
https://github.com/Laxilef/OTGateway.git
synced 2026-12-05 20:53:07 +05:00
fix: require portal authentication for index.html, api/vars and api/info (#311)
This commit is contained in:
1 parent
9537d1dcd2
commit
6b2db61d8f
1 file changed
+7
-4
+7
-4
@@ -172,7 +172,8 @@ static void routes() {
|
||||
});
|
||||
|
||||
// Serve index page
|
||||
webServer->serveStatic("/index.html", LittleFS, "/pages/index.html", PORTAL_CACHE);
|
||||
webServer->serveStatic("/index.html", LittleFS, "/pages/index.html", PORTAL_CACHE)
|
||||
.addMiddleware(&authMiddleware);
|
||||
|
||||
// Serve dashboard page
|
||||
webServer->serveStatic("/dashboard.html", LittleFS, "/pages/dashboard.html", PORTAL_CACHE)
|
||||
@@ -204,7 +205,9 @@ static void routes() {
|
||||
ESP_LOGD(L_PORTAL_WEBSERVER, "Page not found, uri: %s", url.c_str());
|
||||
|
||||
if (url.equals("/index.html")) {
|
||||
request->send(200, "text/plain", "The file system is not flashed!");
|
||||
authMiddleware.run(request, [request]() {
|
||||
request->send(200, "text/plain", "The file system is not flashed!");
|
||||
});
|
||||
|
||||
} else if (getNetworkState(NetworkMode::AP) == NetworkState::PORTAL_STARTED && getRequestInterface(request) == RequestInterface::AP) {
|
||||
onCaptivePortal(request);
|
||||
@@ -1005,7 +1008,7 @@ static void restApi() {
|
||||
// Send response
|
||||
response->setLength();
|
||||
request->send(response);
|
||||
});
|
||||
}).addMiddleware(&authMiddleware);
|
||||
|
||||
// Set vars
|
||||
auto& varsHandler = webServer->on("/api/vars", HTTP_POST, [](AsyncWebServerRequest *request, JsonVariant &requestDoc) {
|
||||
@@ -1111,7 +1114,7 @@ static void restApi() {
|
||||
// Send response
|
||||
response->setLength();
|
||||
request->send(response);
|
||||
});
|
||||
}).addMiddleware(&authMiddleware);
|
||||
|
||||
// Get coredump
|
||||
webServer->on("/api/coredump", HTTP_GET, [](AsyncWebServerRequest* request) {
|
||||
|
||||
Reference in new issue
Block a user