mirror of
https://github.com/home-assistant/core.git
synced 2025-04-26 02:07:54 +00:00
Use new reauth helpers in switcher_kis (#128750)
This commit is contained in:
parent
5fb7bb50e0
commit
ce8893ef6b
@ -10,7 +10,7 @@ from aioswitcher.bridge import SwitcherBase
|
|||||||
from aioswitcher.device.tools import validate_token
|
from aioswitcher.device.tools import validate_token
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_TOKEN, CONF_USERNAME
|
from homeassistant.const import CONF_TOKEN, CONF_USERNAME
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
@ -32,7 +32,6 @@ class SwitcherFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
|
|
||||||
entry: ConfigEntry | None = None
|
|
||||||
username: str | None = None
|
username: str | None = None
|
||||||
token: str | None = None
|
token: str | None = None
|
||||||
discovered_devices: dict[str, SwitcherBase] = {}
|
discovered_devices: dict[str, SwitcherBase] = {}
|
||||||
@ -82,7 +81,6 @@ class SwitcherFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
self, user_input: Mapping[str, Any]
|
self, user_input: Mapping[str, Any]
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle configuration by re-auth."""
|
"""Handle configuration by re-auth."""
|
||||||
self.entry = self.hass.config_entries.async_get_entry(self.context["entry_id"])
|
|
||||||
return await self.async_step_reauth_confirm()
|
return await self.async_step_reauth_confirm()
|
||||||
|
|
||||||
async def async_step_reauth_confirm(
|
async def async_step_reauth_confirm(
|
||||||
@ -90,7 +88,6 @@ class SwitcherFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Dialog that informs the user that reauth is required."""
|
"""Dialog that informs the user that reauth is required."""
|
||||||
errors: dict[str, str] = {}
|
errors: dict[str, str] = {}
|
||||||
assert self.entry is not None
|
|
||||||
|
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
token_is_valid = await validate_token(
|
token_is_valid = await validate_token(
|
||||||
@ -98,7 +95,7 @@ class SwitcherFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
)
|
)
|
||||||
if token_is_valid:
|
if token_is_valid:
|
||||||
return self.async_update_reload_and_abort(
|
return self.async_update_reload_and_abort(
|
||||||
self.entry, data={**self.entry.data, **user_input}
|
self._get_reauth_entry(), data_updates=user_input
|
||||||
)
|
)
|
||||||
errors["base"] = "invalid_auth"
|
errors["base"] = "invalid_auth"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user