1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-27 07:32:22 +01:00

Reduce code duplication in auto-generated API protocol code (#9097)

This commit is contained in:
J. Nick Koston
2025-06-19 02:10:01 +02:00
committed by GitHub
parent b7b1d17ecb
commit a08d021f77
3 changed files with 151 additions and 360 deletions

View File

@@ -379,6 +379,26 @@ class ProtoService {
// Send the buffer
return this->send_buffer(buffer, message_type);
}
// Authentication helper methods
bool check_connection_setup_() {
if (!this->is_connection_setup()) {
this->on_no_setup_connection();
return false;
}
return true;
}
bool check_authenticated_() {
if (!this->check_connection_setup_()) {
return false;
}
if (!this->is_authenticated()) {
this->on_unauthenticated_access();
return false;
}
return true;
}
};
} // namespace api