mirror of
https://github.com/esphome/esphome.git
synced 2025-08-05 09:57:47 +00:00
preen
This commit is contained in:
parent
bb153d42dc
commit
7107b5cfef
@ -1452,14 +1452,10 @@ HelloResponse APIConnection::hello(const HelloRequest &msg) {
|
|||||||
resp.name = App.get_name();
|
resp.name = App.get_name();
|
||||||
|
|
||||||
#ifdef USE_API_PASSWORD
|
#ifdef USE_API_PASSWORD
|
||||||
if (!this->parent_->uses_password()) {
|
// Password required - wait for authentication
|
||||||
// Auto-authenticate if no password is required
|
this->flags_.connection_state = static_cast<uint8_t>(ConnectionState::CONNECTED);
|
||||||
this->complete_authentication_();
|
|
||||||
} else {
|
|
||||||
this->flags_.connection_state = static_cast<uint8_t>(ConnectionState::CONNECTED);
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
// No password support - always auto-authenticate
|
// No password configured - auto-authenticate
|
||||||
this->complete_authentication_();
|
this->complete_authentication_();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1483,7 +1479,7 @@ ConnectResponse APIConnection::connect(const ConnectRequest &msg) {
|
|||||||
DeviceInfoResponse APIConnection::device_info(const DeviceInfoRequest &msg) {
|
DeviceInfoResponse APIConnection::device_info(const DeviceInfoRequest &msg) {
|
||||||
DeviceInfoResponse resp{};
|
DeviceInfoResponse resp{};
|
||||||
#ifdef USE_API_PASSWORD
|
#ifdef USE_API_PASSWORD
|
||||||
resp.uses_password = this->parent_->uses_password();
|
resp.uses_password = true;
|
||||||
#else
|
#else
|
||||||
resp.uses_password = false;
|
resp.uses_password = false;
|
||||||
#endif
|
#endif
|
||||||
|
@ -227,8 +227,6 @@ void APIServer::dump_config() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_API_PASSWORD
|
#ifdef USE_API_PASSWORD
|
||||||
bool APIServer::uses_password() const { return !this->password_.empty(); }
|
|
||||||
|
|
||||||
bool APIServer::check_password(const std::string &password) const {
|
bool APIServer::check_password(const std::string &password) const {
|
||||||
// depend only on input password length
|
// depend only on input password length
|
||||||
const char *a = this->password_.c_str();
|
const char *a = this->password_.c_str();
|
||||||
|
@ -42,7 +42,6 @@ class APIServer : public Component, public Controller {
|
|||||||
bool teardown() override;
|
bool teardown() override;
|
||||||
#ifdef USE_API_PASSWORD
|
#ifdef USE_API_PASSWORD
|
||||||
bool check_password(const std::string &password) const;
|
bool check_password(const std::string &password) const;
|
||||||
bool uses_password() const;
|
|
||||||
void set_password(const std::string &password);
|
void set_password(const std::string &password);
|
||||||
#endif
|
#endif
|
||||||
void set_port(uint16_t port);
|
void set_port(uint16_t port);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user