From 7107b5cfef59e0fcf411f6752d2bdc7f59c81e42 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 11 Jul 2025 10:11:26 -1000 Subject: [PATCH] preen --- esphome/components/api/api_connection.cpp | 12 ++++-------- esphome/components/api/api_server.cpp | 2 -- esphome/components/api/api_server.h | 1 - 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/esphome/components/api/api_connection.cpp b/esphome/components/api/api_connection.cpp index fac3a494ca..3ea88224ed 100644 --- a/esphome/components/api/api_connection.cpp +++ b/esphome/components/api/api_connection.cpp @@ -1452,14 +1452,10 @@ HelloResponse APIConnection::hello(const HelloRequest &msg) { resp.name = App.get_name(); #ifdef USE_API_PASSWORD - if (!this->parent_->uses_password()) { - // Auto-authenticate if no password is required - this->complete_authentication_(); - } else { - this->flags_.connection_state = static_cast(ConnectionState::CONNECTED); - } + // Password required - wait for authentication + this->flags_.connection_state = static_cast(ConnectionState::CONNECTED); #else - // No password support - always auto-authenticate + // No password configured - auto-authenticate this->complete_authentication_(); #endif @@ -1483,7 +1479,7 @@ ConnectResponse APIConnection::connect(const ConnectRequest &msg) { DeviceInfoResponse APIConnection::device_info(const DeviceInfoRequest &msg) { DeviceInfoResponse resp{}; #ifdef USE_API_PASSWORD - resp.uses_password = this->parent_->uses_password(); + resp.uses_password = true; #else resp.uses_password = false; #endif diff --git a/esphome/components/api/api_server.cpp b/esphome/components/api/api_server.cpp index 0915746381..909d0e5e67 100644 --- a/esphome/components/api/api_server.cpp +++ b/esphome/components/api/api_server.cpp @@ -227,8 +227,6 @@ void APIServer::dump_config() { } #ifdef USE_API_PASSWORD -bool APIServer::uses_password() const { return !this->password_.empty(); } - bool APIServer::check_password(const std::string &password) const { // depend only on input password length const char *a = this->password_.c_str(); diff --git a/esphome/components/api/api_server.h b/esphome/components/api/api_server.h index f34fd55974..e4dca8f338 100644 --- a/esphome/components/api/api_server.h +++ b/esphome/components/api/api_server.h @@ -42,7 +42,6 @@ class APIServer : public Component, public Controller { bool teardown() override; #ifdef USE_API_PASSWORD bool check_password(const std::string &password) const; - bool uses_password() const; void set_password(const std::string &password); #endif void set_port(uint16_t port);