mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 14:17:45 +00:00
Use _get_reauth_entry in blue_current config flow (#127328)
This commit is contained in:
parent
da0ebbe57c
commit
74441d2771
@ -14,7 +14,12 @@ from bluecurrent_api.exceptions import (
|
|||||||
)
|
)
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
|
from homeassistant.config_entries import (
|
||||||
|
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
|
||||||
@ -26,7 +31,7 @@ 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 | None = None
|
_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
|
||||||
@ -53,7 +58,7 @@ class BlueCurrentConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
errors["base"] = "unknown"
|
errors["base"] = "unknown"
|
||||||
|
|
||||||
else:
|
else:
|
||||||
if not self._reauth_entry:
|
if self.source != SOURCE_REAUTH:
|
||||||
await self.async_set_unique_id(customer_id)
|
await self.async_set_unique_id(customer_id)
|
||||||
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)
|
||||||
@ -79,7 +84,5 @@ 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.hass.config_entries.async_get_entry(
|
self._reauth_entry = self._get_reauth_entry()
|
||||||
self.context["entry_id"]
|
|
||||||
)
|
|
||||||
return await self.async_step_user()
|
return await self.async_step_user()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user