mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Use reauth helpers in blue_current config flow (#127434)
* Use async_update_reload_and_abort in blue_current config flow * Adjust
This commit is contained in:
parent
045d96cdd1
commit
c957c7a515
@ -14,12 +14,7 @@ from bluecurrent_api.exceptions import (
|
|||||||
)
|
)
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.config_entries import (
|
from homeassistant.config_entries import SOURCE_REAUTH, ConfigFlow, ConfigFlowResult
|
||||||
SOURCE_REAUTH,
|
|
||||||
ConfigEntry,
|
|
||||||
ConfigFlow,
|
|
||||||
ConfigFlowResult,
|
|
||||||
)
|
|
||||||
from homeassistant.const import CONF_API_TOKEN
|
from homeassistant.const import CONF_API_TOKEN
|
||||||
|
|
||||||
from .const import DOMAIN, LOGGER
|
from .const import DOMAIN, LOGGER
|
||||||
@ -31,7 +26,6 @@ class BlueCurrentConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
"""Handle the config flow for Blue Current."""
|
"""Handle the config flow for Blue Current."""
|
||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
_reauth_entry: ConfigEntry
|
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
@ -63,14 +57,11 @@ class BlueCurrentConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
self._abort_if_unique_id_configured()
|
self._abort_if_unique_id_configured()
|
||||||
return self.async_create_entry(title=email, data=user_input)
|
return self.async_create_entry(title=email, data=user_input)
|
||||||
|
|
||||||
if self._reauth_entry.unique_id == customer_id:
|
reauth_entry = self._get_reauth_entry()
|
||||||
self.hass.config_entries.async_update_entry(
|
if reauth_entry.unique_id == customer_id:
|
||||||
self._reauth_entry, data=user_input
|
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(
|
return self.async_abort(
|
||||||
reason="wrong_account",
|
reason="wrong_account",
|
||||||
@ -84,5 +75,4 @@ class BlueCurrentConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
self, entry_data: Mapping[str, Any]
|
self, entry_data: Mapping[str, Any]
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle a reauthorization flow request."""
|
"""Handle a reauthorization flow request."""
|
||||||
self._reauth_entry = self._get_reauth_entry()
|
|
||||||
return await self.async_step_user()
|
return await self.async_step_user()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user