mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Use reauth helpers in lacrosse_view (#128655)
This commit is contained in:
parent
d6703b20d3
commit
f3f6cb03e6
@ -9,7 +9,7 @@ from typing import Any
|
|||||||
from lacrosse_view import LaCrosse, Location, LoginError
|
from lacrosse_view import LaCrosse, Location, LoginError
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
|
from homeassistant.config_entries import SOURCE_REAUTH, ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
@ -54,7 +54,6 @@ class LaCrosseViewConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
"""Initialize the config flow."""
|
"""Initialize the config flow."""
|
||||||
self.data: dict[str, str] = {}
|
self.data: dict[str, str] = {}
|
||||||
self.locations: list[Location] = []
|
self.locations: list[Location] = []
|
||||||
self._reauth_entry: ConfigEntry | None = None
|
|
||||||
|
|
||||||
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
|
||||||
@ -83,12 +82,10 @@ class LaCrosseViewConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
self.locations = info
|
self.locations = info
|
||||||
|
|
||||||
# Check if we are reauthenticating
|
# Check if we are reauthenticating
|
||||||
if self._reauth_entry is not None:
|
if self.source == SOURCE_REAUTH:
|
||||||
self.hass.config_entries.async_update_entry(
|
return self.async_update_reload_and_abort(
|
||||||
self._reauth_entry, data=self._reauth_entry.data | self.data
|
self._get_reauth_entry(), data_updates=self.data
|
||||||
)
|
)
|
||||||
await self.hass.config_entries.async_reload(self._reauth_entry.entry_id)
|
|
||||||
return self.async_abort(reason="reauth_successful")
|
|
||||||
|
|
||||||
_LOGGER.debug("Moving on to location step")
|
_LOGGER.debug("Moving on to location step")
|
||||||
return await self.async_step_location()
|
return await self.async_step_location()
|
||||||
@ -139,9 +136,6 @@ class LaCrosseViewConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
self, entry_data: Mapping[str, Any]
|
self, entry_data: Mapping[str, Any]
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Reauth in case of a password change or other error."""
|
"""Reauth in case of a password change or other error."""
|
||||||
self._reauth_entry = self.hass.config_entries.async_get_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