mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 08:47:57 +00:00
Use new reauth_helpers in mikrotik (#128693)
This commit is contained in:
parent
e22fb444d3
commit
0cb07f511a
@ -39,7 +39,6 @@ class MikrotikFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a Mikrotik config flow."""
|
||||
|
||||
VERSION = 1
|
||||
_reauth_entry: ConfigEntry | None
|
||||
|
||||
@staticmethod
|
||||
@callback
|
||||
@ -87,9 +86,6 @@ class MikrotikFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
self, entry_data: Mapping[str, Any]
|
||||
) -> ConfigFlowResult:
|
||||
"""Perform reauth upon an API authentication error."""
|
||||
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(
|
||||
@ -97,9 +93,10 @@ class MikrotikFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
) -> ConfigFlowResult:
|
||||
"""Confirm reauth dialog."""
|
||||
errors = {}
|
||||
assert self._reauth_entry
|
||||
|
||||
reauth_entry = self._get_reauth_entry()
|
||||
if user_input is not None:
|
||||
user_input = {**self._reauth_entry.data, **user_input}
|
||||
user_input = {**reauth_entry.data, **user_input}
|
||||
try:
|
||||
await self.hass.async_add_executor_job(get_api, user_input)
|
||||
except CannotConnect:
|
||||
@ -108,17 +105,10 @@ class MikrotikFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
errors[CONF_PASSWORD] = "invalid_auth"
|
||||
|
||||
if not errors:
|
||||
self.hass.config_entries.async_update_entry(
|
||||
self._reauth_entry,
|
||||
data=user_input,
|
||||
)
|
||||
await self.hass.config_entries.async_reload(self._reauth_entry.entry_id)
|
||||
return self.async_abort(reason="reauth_successful")
|
||||
return self.async_update_reload_and_abort(reauth_entry, data=user_input)
|
||||
|
||||
return self.async_show_form(
|
||||
description_placeholders={
|
||||
CONF_USERNAME: self._reauth_entry.data[CONF_USERNAME]
|
||||
},
|
||||
description_placeholders={CONF_USERNAME: reauth_entry.data[CONF_USERNAME]},
|
||||
step_id="reauth_confirm",
|
||||
data_schema=vol.Schema(
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user