mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 22:27:07 +00:00
Use new reauth helpers in vodafone_station (#128781)
This commit is contained in:
parent
6f9c99ac6c
commit
5f04a6239e
@ -60,7 +60,6 @@ class VodafoneStationConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
"""Handle a config flow for Vodafone Station."""
|
"""Handle a config flow for Vodafone Station."""
|
||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
entry: ConfigEntry | None = None
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@callback
|
@callback
|
||||||
@ -106,21 +105,19 @@ class VodafoneStationConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
self, entry_data: Mapping[str, Any]
|
self, entry_data: Mapping[str, Any]
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle reauth flow."""
|
"""Handle reauth flow."""
|
||||||
self.entry = self.hass.config_entries.async_get_entry(self.context["entry_id"])
|
self.context["title_placeholders"] = {"host": entry_data[CONF_HOST]}
|
||||||
assert self.entry
|
|
||||||
self.context["title_placeholders"] = {"host": self.entry.data[CONF_HOST]}
|
|
||||||
return await self.async_step_reauth_confirm()
|
return await self.async_step_reauth_confirm()
|
||||||
|
|
||||||
async def async_step_reauth_confirm(
|
async def async_step_reauth_confirm(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle reauth confirm."""
|
"""Handle reauth confirm."""
|
||||||
assert self.entry
|
|
||||||
errors = {}
|
errors = {}
|
||||||
|
|
||||||
|
reauth_entry = self._get_reauth_entry()
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
try:
|
try:
|
||||||
await validate_input(self.hass, {**self.entry.data, **user_input})
|
await validate_input(self.hass, {**reauth_entry.data, **user_input})
|
||||||
except aiovodafone_exceptions.AlreadyLogged:
|
except aiovodafone_exceptions.AlreadyLogged:
|
||||||
errors["base"] = "already_logged"
|
errors["base"] = "already_logged"
|
||||||
except aiovodafone_exceptions.CannotConnect:
|
except aiovodafone_exceptions.CannotConnect:
|
||||||
@ -131,21 +128,16 @@ class VodafoneStationConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
_LOGGER.exception("Unexpected exception")
|
_LOGGER.exception("Unexpected exception")
|
||||||
errors["base"] = "unknown"
|
errors["base"] = "unknown"
|
||||||
else:
|
else:
|
||||||
self.hass.config_entries.async_update_entry(
|
return self.async_update_reload_and_abort(
|
||||||
self.entry,
|
reauth_entry,
|
||||||
data={
|
data_updates={
|
||||||
**self.entry.data,
|
|
||||||
CONF_PASSWORD: user_input[CONF_PASSWORD],
|
CONF_PASSWORD: user_input[CONF_PASSWORD],
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
self.hass.async_create_task(
|
|
||||||
self.hass.config_entries.async_reload(self.entry.entry_id)
|
|
||||||
)
|
|
||||||
return self.async_abort(reason="reauth_successful")
|
|
||||||
|
|
||||||
return self.async_show_form(
|
return self.async_show_form(
|
||||||
step_id="reauth_confirm",
|
step_id="reauth_confirm",
|
||||||
description_placeholders={CONF_HOST: self.entry.data[CONF_HOST]},
|
description_placeholders={CONF_HOST: reauth_entry.data[CONF_HOST]},
|
||||||
data_schema=STEP_REAUTH_DATA_SCHEMA,
|
data_schema=STEP_REAUTH_DATA_SCHEMA,
|
||||||
errors=errors,
|
errors=errors,
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user