mirror of
https://github.com/home-assistant/core.git
synced 2025-07-29 16:17:20 +00:00
Use reauth helpers in fujitsu_fglair (#128570)
This commit is contained in:
parent
35ff3afa12
commit
937d15d7e1
@ -8,7 +8,7 @@ from ayla_iot_unofficial import AylaAuthError, new_ayla_api
|
|||||||
from ayla_iot_unofficial.fujitsu_consts import FGLAIR_APP_CREDENTIALS
|
from ayla_iot_unofficial.fujitsu_consts import FGLAIR_APP_CREDENTIALS
|
||||||
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_PASSWORD, CONF_USERNAME
|
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
||||||
from homeassistant.helpers import aiohttp_client
|
from homeassistant.helpers import aiohttp_client
|
||||||
from homeassistant.helpers.selector import SelectSelector, SelectSelectorConfig
|
from homeassistant.helpers.selector import SelectSelector, SelectSelectorConfig
|
||||||
@ -41,7 +41,6 @@ class FGLairConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
"""Handle a config flow for Fujitsu HVAC (based on Ayla IOT)."""
|
"""Handle a config flow for Fujitsu HVAC (based on Ayla IOT)."""
|
||||||
|
|
||||||
MINOR_VERSION = 2
|
MINOR_VERSION = 2
|
||||||
_reauth_entry: ConfigEntry | None = None
|
|
||||||
|
|
||||||
async def _async_validate_credentials(
|
async def _async_validate_credentials(
|
||||||
self, user_input: dict[str, Any]
|
self, user_input: dict[str, Any]
|
||||||
@ -93,9 +92,6 @@ class FGLairConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
self, entry_data: Mapping[str, Any]
|
self, entry_data: Mapping[str, Any]
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Perform reauth upon an API authentication error."""
|
"""Perform reauth upon an API authentication error."""
|
||||||
self._reauth_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(
|
||||||
@ -103,25 +99,23 @@ class FGLairConfigFlow(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._reauth_entry
|
|
||||||
|
|
||||||
|
reauth_entry = self._get_reauth_entry()
|
||||||
if user_input:
|
if user_input:
|
||||||
reauth_data = {
|
errors = await self._async_validate_credentials(
|
||||||
**self._reauth_entry.data,
|
reauth_entry.data | user_input
|
||||||
CONF_PASSWORD: user_input[CONF_PASSWORD],
|
)
|
||||||
}
|
|
||||||
errors = await self._async_validate_credentials(reauth_data)
|
|
||||||
|
|
||||||
if len(errors) == 0:
|
if not errors:
|
||||||
return self.async_update_reload_and_abort(
|
return self.async_update_reload_and_abort(
|
||||||
self._reauth_entry, data=reauth_data
|
reauth_entry, data_updates=user_input
|
||||||
)
|
)
|
||||||
|
|
||||||
return self.async_show_form(
|
return self.async_show_form(
|
||||||
step_id="reauth_confirm",
|
step_id="reauth_confirm",
|
||||||
data_schema=STEP_REAUTH_DATA_SCHEMA,
|
data_schema=STEP_REAUTH_DATA_SCHEMA,
|
||||||
description_placeholders={
|
description_placeholders={
|
||||||
CONF_USERNAME: self._reauth_entry.data[CONF_USERNAME],
|
CONF_USERNAME: reauth_entry.data[CONF_USERNAME],
|
||||||
**self.context["title_placeholders"],
|
**self.context["title_placeholders"],
|
||||||
},
|
},
|
||||||
errors=errors,
|
errors=errors,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user