mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 18:57:06 +00:00
Use new reauth helpers in unifiprotect (#128775)
This commit is contained in:
parent
062b61affb
commit
fd8f5b9ff0
@ -104,7 +104,6 @@ class ProtectFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
def __init__(self) -> None:
|
||||
"""Init the config flow."""
|
||||
super().__init__()
|
||||
self.entry: ConfigEntry | None = None
|
||||
self._discovered_device: dict[str, str] = {}
|
||||
|
||||
async def async_step_dhcp(
|
||||
@ -295,8 +294,6 @@ class ProtectFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
self, entry_data: Mapping[str, Any]
|
||||
) -> ConfigFlowResult:
|
||||
"""Perform reauth upon an API authentication error."""
|
||||
|
||||
self.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(
|
||||
@ -304,21 +301,21 @@ class ProtectFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
) -> ConfigFlowResult:
|
||||
"""Confirm reauth."""
|
||||
errors: dict[str, str] = {}
|
||||
assert self.entry is not None
|
||||
|
||||
# prepopulate fields
|
||||
form_data = {**self.entry.data}
|
||||
reauth_entry = self._get_reauth_entry()
|
||||
form_data = {**reauth_entry.data}
|
||||
if user_input is not None:
|
||||
form_data.update(user_input)
|
||||
|
||||
# validate login data
|
||||
_, errors = await self._async_get_nvr_data(form_data)
|
||||
if not errors:
|
||||
return self.async_update_reload_and_abort(self.entry, data=form_data)
|
||||
return self.async_update_reload_and_abort(reauth_entry, data=form_data)
|
||||
|
||||
self.context["title_placeholders"] = {
|
||||
"name": self.entry.title,
|
||||
"ip_address": self.entry.data[CONF_HOST],
|
||||
"name": reauth_entry.title,
|
||||
"ip_address": reauth_entry.data[CONF_HOST],
|
||||
}
|
||||
return self.async_show_form(
|
||||
step_id="reauth_confirm",
|
||||
|
Loading…
x
Reference in New Issue
Block a user