Use reauth helpers in brunt config flow (#127438)
parent
c634f6067a
commit
09014e3390
|
@ -11,7 +11,7 @@ from aiohttp.client_exceptions import ServerDisconnectedError
|
|||
from brunt import BruntClientAsync
|
||||
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_USERNAME
|
||||
|
||||
from .const import DOMAIN
|
||||
|
@ -56,8 +56,6 @@ class BruntConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||
|
||||
VERSION = 1
|
||||
|
||||
_reauth_entry: ConfigEntry
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> ConfigFlowResult:
|
||||
|
@ -82,14 +80,14 @@ class BruntConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||
self, entry_data: Mapping[str, Any]
|
||||
) -> ConfigFlowResult:
|
||||
"""Perform reauth upon an API authentication error."""
|
||||
self._reauth_entry = self._get_reauth_entry()
|
||||
return await self.async_step_reauth_confirm()
|
||||
|
||||
async def async_step_reauth_confirm(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> ConfigFlowResult:
|
||||
"""Dialog that informs the user that reauth is required."""
|
||||
username = self._reauth_entry.data[CONF_USERNAME]
|
||||
reauth_entry = self._get_reauth_entry()
|
||||
username = reauth_entry.data[CONF_USERNAME]
|
||||
if user_input is None:
|
||||
return self.async_show_form(
|
||||
step_id="reauth_confirm",
|
||||
|
@ -106,6 +104,4 @@ class BruntConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||
description_placeholders={"username": username},
|
||||
)
|
||||
|
||||
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)
|
||||
|
|
Loading…
Reference in New Issue