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
|
// 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
|
// Serve dashboard page
|
||||||
webServer->serveStatic("/dashboard.html", LittleFS, "/pages/dashboard.html", PORTAL_CACHE)
|
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());
|
ESP_LOGD(L_PORTAL_WEBSERVER, "Page not found, uri: %s", url.c_str());
|
||||||
|
|
||||||
if (url.equals("/index.html")) {
|
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) {
|
} else if (getNetworkState(NetworkMode::AP) == NetworkState::PORTAL_STARTED && getRequestInterface(request) == RequestInterface::AP) {
|
||||||
onCaptivePortal(request);
|
onCaptivePortal(request);
|
||||||
@@ -1005,7 +1008,7 @@ static void restApi() {
|
|||||||
// Send response
|
// Send response
|
||||||
response->setLength();
|
response->setLength();
|
||||||
request->send(response);
|
request->send(response);
|
||||||
});
|
}).addMiddleware(&authMiddleware);
|
||||||
|
|
||||||
// Set vars
|
// Set vars
|
||||||
auto& varsHandler = webServer->on("/api/vars", HTTP_POST, [](AsyncWebServerRequest *request, JsonVariant &requestDoc) {
|
auto& varsHandler = webServer->on("/api/vars", HTTP_POST, [](AsyncWebServerRequest *request, JsonVariant &requestDoc) {
|
||||||
@@ -1111,7 +1114,7 @@ static void restApi() {
|
|||||||
// Send response
|
// Send response
|
||||||
response->setLength();
|
response->setLength();
|
||||||
request->send(response);
|
request->send(response);
|
||||||
});
|
}).addMiddleware(&authMiddleware);
|
||||||
|
|
||||||
// Get coredump
|
// Get coredump
|
||||||
webServer->on("/api/coredump", HTTP_GET, [](AsyncWebServerRequest* request) {
|
webServer->on("/api/coredump", HTTP_GET, [](AsyncWebServerRequest* request) {
|
||||||
|
|||||||
Reference in new issue
Block a user