Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use void handleHandshake(AwsHandshakeHandler handler) for cookie handling? #13

Open
DaeMonSxy opened this issue Dec 4, 2024 · 0 comments

Comments

@DaeMonSxy
Copy link

How to use properly the cookie auth instead of request->authenticate ?
Do we need to use it for webpages and ws also, or only in server.on- (headers request) enough?

WServer.on("/syst", HTTP_GET, [](AsyncWebServerRequest *request) {
        sendHTMLResponse(request, system_html, sizeof(system_html), (TEXT_HTML), P_SYSTEM);
    });


void sendHTMLResponse(AsyncWebServerRequest *request, const uint8_t *htmlContent, size_t htmlSize, const char *contentType, html_pages_t setpage)
{
   
  if (dev_auth && !request->authenticate(dev_user, dev_pass))
        return request->requestAuthentication();
 

#if defined(ESP32)
    AsyncWebServerResponse *response = request->beginResponse(200, contentType, htmlContent, htmlSize);
#elif defined(ESP8266)
    AsyncWebServerResponse *response = request->beginResponse_P(200, contentType, htmlContent, htmlSize);
#endif

    response->addHeader((CONTENT_ENCODING), (GZIP));
    request->send(response);

    current_html_page = setpage;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant