mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 12:47:08 +00:00
Use reauth_confirm in mqtt (#128696)
This commit is contained in:
parent
a023b71ce0
commit
22491afa58
@ -210,7 +210,6 @@ class FlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
|
|
||||||
entry: ConfigEntry | None
|
|
||||||
_hassio_discovery: dict[str, Any] | None = None
|
_hassio_discovery: dict[str, Any] | None = None
|
||||||
_addon_manager: AddonManager
|
_addon_manager: AddonManager
|
||||||
|
|
||||||
@ -398,7 +397,6 @@ class FlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
self, entry_data: Mapping[str, Any]
|
self, entry_data: Mapping[str, Any]
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle re-authentication with MQTT broker."""
|
"""Handle re-authentication with MQTT broker."""
|
||||||
self.entry = self.hass.config_entries.async_get_entry(self.context["entry_id"])
|
|
||||||
if is_hassio(self.hass):
|
if is_hassio(self.hass):
|
||||||
# Check if entry setup matches the add-on discovery config
|
# Check if entry setup matches the add-on discovery config
|
||||||
addon_manager = get_addon_manager(self.hass)
|
addon_manager = get_addon_manager(self.hass)
|
||||||
@ -437,18 +435,18 @@ class FlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
"""Confirm re-authentication with MQTT broker."""
|
"""Confirm re-authentication with MQTT broker."""
|
||||||
errors: dict[str, str] = {}
|
errors: dict[str, str] = {}
|
||||||
|
|
||||||
assert self.entry is not None
|
reauth_entry = self._get_reauth_entry()
|
||||||
if user_input:
|
if user_input:
|
||||||
substituted_used_data = update_password_from_user_input(
|
substituted_used_data = update_password_from_user_input(
|
||||||
self.entry.data.get(CONF_PASSWORD), user_input
|
reauth_entry.data.get(CONF_PASSWORD), user_input
|
||||||
)
|
)
|
||||||
new_entry_data = {**self.entry.data, **substituted_used_data}
|
new_entry_data = {**reauth_entry.data, **substituted_used_data}
|
||||||
if await self.hass.async_add_executor_job(
|
if await self.hass.async_add_executor_job(
|
||||||
try_connection,
|
try_connection,
|
||||||
new_entry_data,
|
new_entry_data,
|
||||||
):
|
):
|
||||||
return self.async_update_reload_and_abort(
|
return self.async_update_reload_and_abort(
|
||||||
self.entry, data=new_entry_data
|
reauth_entry, data=new_entry_data
|
||||||
)
|
)
|
||||||
|
|
||||||
errors["base"] = "invalid_auth"
|
errors["base"] = "invalid_auth"
|
||||||
@ -456,7 +454,7 @@ class FlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
schema = self.add_suggested_values_to_schema(
|
schema = self.add_suggested_values_to_schema(
|
||||||
REAUTH_SCHEMA,
|
REAUTH_SCHEMA,
|
||||||
{
|
{
|
||||||
CONF_USERNAME: self.entry.data.get(CONF_USERNAME),
|
CONF_USERNAME: reauth_entry.data.get(CONF_USERNAME),
|
||||||
CONF_PASSWORD: PWD_NOT_CHANGED,
|
CONF_PASSWORD: PWD_NOT_CHANGED,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user