1
0
mirror of https://github.com/esphome/esphome.git synced 2026-02-09 01:01:56 +00:00

Compare commits

...

1 Commits

Author SHA1 Message Date
J. Nick Koston
491112db69 Generate auth check unconditionally in read_message
If all messages required auth (both no_conn_ids and conn_only_ids
empty), the auth check block would be skipped entirely. Now generates
a simple check_authenticated_() call as fallback when there are no
exceptions to the default auth requirement.
2026-02-08 10:23:22 -06:00

View File

@@ -2930,8 +2930,8 @@ static const char *const TAG = "api.service";
out = f"void {class_name}::read_message(uint32_t msg_size, uint32_t msg_type, const uint8_t *msg_data) {{\n"
# Auth check block before dispatch switch
out += " // Check authentication/connection requirements\n"
if no_conn_ids or conn_only_ids:
out += " // Check authentication/connection requirements\n"
out += " switch (msg_type) {\n"
if no_conn_ids:
@@ -2951,6 +2951,10 @@ static const char *const TAG = "api.service";
out += " }\n"
out += " break;\n"
out += " }\n"
else:
out += " if (!this->check_authenticated_()) {\n"
out += " return;\n"
out += " }\n"
# Dispatch switch
out += " switch (msg_type) {\n"