Harden bridge state and reauthentication handling

This commit is contained in:
2026-09-04 13:07:21 +02:00
parent 9766f7f9b2
commit 1d51e56272
9 changed files with 264 additions and 12 deletions
+11 -1
View File
@@ -160,13 +160,23 @@ class MBSecureConfigFlow(ConfigFlow, domain=DOMAIN):
if user_input is not None:
reauth_entry = self._get_reauth_entry()
candidate = {**reauth_entry.data, CONF_TOKEN: user_input[CONF_TOKEN]}
error, _ = await self._async_validate(candidate)
error, info = await self._async_validate(candidate)
if error is None:
assert info is not None
if info.bridge_id is None:
errors["base"] = "missing_bridge_id"
return self._show_reauth_form(errors)
await self.async_set_unique_id(info.bridge_id)
self._abort_if_unique_id_mismatch(reason="wrong_account")
return self.async_update_reload_and_abort(
reauth_entry,
data_updates={CONF_TOKEN: user_input[CONF_TOKEN]},
)
errors["base"] = error
return self._show_reauth_form(errors)
def _show_reauth_form(self, errors: dict[str, str]) -> ConfigFlowResult:
"""Show the bridge token replacement form."""
return self.async_show_form(
step_id="reauth_confirm",
data_schema=vol.Schema(