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

7. Fix auth #187

Merged
merged 1 commit into from
Dec 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading