mirror of
https://github.com/home-assistant/core.git
synced 2025-07-26 14:47:38 +00:00
Use reauth helpers in fibaro (#128567)
This commit is contained in:
parent
5fa6202111
commit
275c86a0a9
@ -9,7 +9,7 @@ from typing import Any
|
||||
from slugify import slugify
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.const import CONF_PASSWORD, CONF_URL, CONF_USERNAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
@ -63,10 +63,6 @@ class FibaroConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
|
||||
VERSION = 1
|
||||
|
||||
def __init__(self) -> None:
|
||||
"""Initialize."""
|
||||
self._reauth_entry: ConfigEntry | None = None
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> ConfigFlowResult:
|
||||
@ -94,9 +90,6 @@ class FibaroConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
self, entry_data: Mapping[str, Any]
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle reauthentication."""
|
||||
self._reauth_entry = self.hass.config_entries.async_get_entry(
|
||||
self.context["entry_id"]
|
||||
)
|
||||
return await self.async_step_reauth_confirm()
|
||||
|
||||
async def async_step_reauth_confirm(
|
||||
@ -105,9 +98,10 @@ class FibaroConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a flow initiated by reauthentication."""
|
||||
errors = {}
|
||||
|
||||
assert self._reauth_entry
|
||||
reauth_entry = self._get_reauth_entry()
|
||||
|
||||
if user_input is not None:
|
||||
new_data = self._reauth_entry.data | user_input
|
||||
new_data = reauth_entry.data | user_input
|
||||
try:
|
||||
await _validate_input(self.hass, new_data)
|
||||
except FibaroConnectFailed:
|
||||
@ -115,19 +109,13 @@ class FibaroConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
except FibaroAuthFailed:
|
||||
errors["base"] = "invalid_auth"
|
||||
else:
|
||||
self.hass.config_entries.async_update_entry(
|
||||
self._reauth_entry, data=new_data
|
||||
return self.async_update_reload_and_abort(
|
||||
reauth_entry, data_updates=user_input
|
||||
)
|
||||
self.hass.async_create_task(
|
||||
self.hass.config_entries.async_reload(self._reauth_entry.entry_id)
|
||||
)
|
||||
return self.async_abort(reason="reauth_successful")
|
||||
|
||||
return self.async_show_form(
|
||||
step_id="reauth_confirm",
|
||||
data_schema=vol.Schema({vol.Required(CONF_PASSWORD): str}),
|
||||
errors=errors,
|
||||
description_placeholders={
|
||||
CONF_USERNAME: self._reauth_entry.data[CONF_USERNAME]
|
||||
},
|
||||
description_placeholders={CONF_USERNAME: reauth_entry.data[CONF_USERNAME]},
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user