mirror of
https://github.com/esphome/esphome.git
synced 2026-09-17 10:08:40 +00:00
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.
This commit is contained in:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user