Use reauth helpers in blue_current config flow (#127434)
* Use async_update_reload_and_abort in blue_current config flow * Adjustpull/127439/head
parent
045d96cdd1
commit
c957c7a515
|
@ -14,12 +14,7 @@ from bluecurrent_api.exceptions import (
|
|||
)
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.config_entries import (
|
||||
SOURCE_REAUTH,
|
||||
ConfigEntry,
|
||||
ConfigFlow,
|
||||
ConfigFlowResult,
|
||||
)
|
||||
from homeassistant.config_entries import SOURCE_REAUTH, ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.const import CONF_API_TOKEN
|
||||
|
||||
from .const import DOMAIN, LOGGER
|
||||
|
@ -31,7 +26,6 @@ class BlueCurrentConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||
"""Handle the config flow for Blue Current."""
|
||||
|
||||
VERSION = 1
|
||||
_reauth_entry: ConfigEntry
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
|
@ -63,14 +57,11 @@ class BlueCurrentConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||
self._abort_if_unique_id_configured()
|
||||
return self.async_create_entry(title=email, data=user_input)
|
||||
|
||||
if self._reauth_entry.unique_id == customer_id:
|
||||
self.hass.config_entries.async_update_entry(
|
||||
self._reauth_entry, data=user_input
|
||||
reauth_entry = self._get_reauth_entry()
|
||||
if reauth_entry.unique_id == customer_id:
|
||||
return self.async_update_reload_and_abort(
|
||||
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_abort(
|
||||
reason="wrong_account",
|
||||
|
@ -84,5 +75,4 @@ class BlueCurrentConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||
self, entry_data: Mapping[str, Any]
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle a reauthorization flow request."""
|
||||
self._reauth_entry = self._get_reauth_entry()
|
||||
return await self.async_step_user()
|
||||
|
|
Loading…
Reference in New Issue