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:
@@ -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
|
||||
|
Reference in New Issue
Block a user