Use reauth helpers in blue_current config flow (#127434)

* Use async_update_reload_and_abort in blue_current config flow

* Adjust
pull/127439/head
epenet 2024-10-03 14:40:12 +02:00 committed by GitHub
parent 045d96cdd1
commit c957c7a515
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 15 deletions

View File

@ -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()