static void handle_info_cb(AsyncWebServerRequest *request) {
#ifndef RELEASE
String webpage;
if (!setup_complete()) return;
if (!authenticated()) return;
if (!webpage.reserve(4*1024)) {
log_print(F("HTTP: failed to allocate memory\n"));
}
html_insert_page_header(webpage);
html_insert_page_body(webpage);
html_insert_page_menu(webpage);
html_insert_info_content(webpage);
html_insert_page_footer(webpage);
request->send(200, "text/html", webpage);
system_count_net_traffic(webpage.length());
#endif
}
static bool authenticated(AsyncWebServerRequest *request) {
String header;
if (request->hasHeader("Cookie")){
String cookie = request->header("Cookie");
String name = "GENESYS_SESSION_KEY=";
if (cookie.indexOf(name + session_key) != -1) {
return (true);
}
}
AsyncWebServerResponse *response = request->beginResponse(301);
response->addHeader("Location","/login");
response->addHeader("Cache-Control"," no-cache");
request->send(response);
system_count_net_traffic(header.length());
return (false);
}