nailbuster / myWebServerAsync

myWebServer Async library for esp8266 arduino ide
GNU Lesser General Public License v2.1
11 stars 6 forks source link

Authentication doesn't work #3

Open Lymkin opened 5 years ago

Lymkin commented 5 years ago

It seems as though authentication does not work on the ASync version of your WebServer.

Lymkin commented 5 years ago

I got authentication to work by changing the isAdmin function in "myWebServerAsync.cpp" to the following:

bool isAdmin(AsyncWebServerRequest *request)
{
    if (ConfigPassword == "") return true; //not using web password (default);
    bool isAuth = false;
    //String realm = "*";
    if (!request->authenticate(ConfigUsername.c_str(), ConfigPassword.c_str())) {
        request->requestAuthentication();
        isAuth = false;
    }
    else {
        isAuth = true;
    }
    return isAuth;
}