Skip to content

Commit

Permalink
Merge pull request #187 from mathieucarbou/auth
Browse files Browse the repository at this point in the history
7. Fix auth
  • Loading branch information
ayushsharma82 authored Dec 16, 2023
2 parents 2556e23 + 3aa61d4 commit b677bf6
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/ESPDash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,13 @@ ESPDash::ESPDash(AsyncWebServer* server, const char* uri, bool enable_default_st
_server->addHandler(_ws);
}

void ESPDash::setAuthentication(const char* user, const char* pass) {
strncpy(username, user, sizeof(username));
strncpy(password, pass, sizeof(password));
basic_auth = true;
_ws->setAuthentication(username, password);
void ESPDash::setAuthentication(const char *user, const char *pass) {
basic_auth = strlen(user) > 0 && strlen(pass) > 0;
if(basic_auth) {
strncpy(username, user, sizeof(username));
strncpy(password, pass, sizeof(password));
_ws->setAuthentication(user, pass);
}
}

void ESPDash::setAuthentication(const String &user, const String &pass) {
Expand Down

0 comments on commit b677bf6

Please sign in to comment.