mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Use new reauth_helpers in onvif (#128705)
This commit is contained in:
parent
5816342bed
commit
157e7f9f78
@ -102,7 +102,6 @@ class OnvifFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
"""Handle a ONVIF config flow."""
|
"""Handle a ONVIF config flow."""
|
||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
_reauth_entry: ConfigEntry
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@callback
|
@callback
|
||||||
@ -136,30 +135,28 @@ class OnvifFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
self, entry_data: Mapping[str, Any]
|
self, entry_data: Mapping[str, Any]
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle re-authentication of an existing config entry."""
|
"""Handle re-authentication of an existing config entry."""
|
||||||
reauth_entry = self.hass.config_entries.async_get_entry(
|
|
||||||
self.context["entry_id"]
|
|
||||||
)
|
|
||||||
assert reauth_entry is not None
|
|
||||||
self._reauth_entry = reauth_entry
|
|
||||||
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:
|
||||||
"""Confirm reauth."""
|
"""Confirm reauth."""
|
||||||
entry = self._reauth_entry
|
|
||||||
errors: dict[str, str] | None = {}
|
errors: dict[str, str] | None = {}
|
||||||
|
reauth_entry = self._get_reauth_entry()
|
||||||
description_placeholders: dict[str, str] | None = None
|
description_placeholders: dict[str, str] | None = None
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
entry_data = entry.data
|
self.onvif_config = reauth_entry.data | user_input
|
||||||
self.onvif_config = entry_data | user_input
|
|
||||||
errors, description_placeholders = await self.async_setup_profiles(
|
errors, description_placeholders = await self.async_setup_profiles(
|
||||||
configure_unique_id=False
|
configure_unique_id=False
|
||||||
)
|
)
|
||||||
if not errors:
|
if not errors:
|
||||||
return self.async_update_reload_and_abort(entry, data=self.onvif_config)
|
return self.async_update_reload_and_abort(
|
||||||
|
reauth_entry, data=self.onvif_config
|
||||||
|
)
|
||||||
|
|
||||||
username = (user_input or {}).get(CONF_USERNAME) or entry.data[CONF_USERNAME]
|
username = (user_input or {}).get(CONF_USERNAME) or reauth_entry.data[
|
||||||
|
CONF_USERNAME
|
||||||
|
]
|
||||||
return self.async_show_form(
|
return self.async_show_form(
|
||||||
step_id="reauth_confirm",
|
step_id="reauth_confirm",
|
||||||
data_schema=vol.Schema(
|
data_schema=vol.Schema(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user