Use reauth helpers in linear_garage_door (#128658)

pull/128681/head
epenet 2024-10-18 17:17:31 +02:00 committed by GitHub
parent f3f6cb03e6
commit 47b809c7b7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 12 deletions

View File

@ -11,7 +11,7 @@ from linear_garage_door import Linear
from linear_garage_door.errors import InvalidLoginError
import voluptuous as vol
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
from homeassistant.config_entries import SOURCE_REAUTH, ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import HomeAssistantError
@ -69,7 +69,6 @@ class LinearGarageDoorConfigFlow(ConfigFlow, domain=DOMAIN):
def __init__(self) -> None:
"""Initialize the config flow."""
self.data: dict[str, Sequence[Collection[str]]] = {}
self._reauth_entry: ConfigEntry | None = None
async def async_step_user(
self, user_input: dict[str, Any] | None = None
@ -93,14 +92,14 @@ class LinearGarageDoorConfigFlow(ConfigFlow, domain=DOMAIN):
self.data = info
# Check if we are reauthenticating
if self._reauth_entry is not None:
self.hass.config_entries.async_update_entry(
self._reauth_entry,
data=self._reauth_entry.data
| {"email": self.data["email"], "password": self.data["password"]},
if self.source == SOURCE_REAUTH:
return self.async_update_reload_and_abort(
self._get_reauth_entry(),
data_updates={
CONF_EMAIL: self.data["email"],
CONF_PASSWORD: self.data["password"],
},
)
await self.hass.config_entries.async_reload(self._reauth_entry.entry_id)
return self.async_abort(reason="reauth_successful")
return await self.async_step_site()
@ -150,9 +149,6 @@ class LinearGarageDoorConfigFlow(ConfigFlow, domain=DOMAIN):
self, entry_data: Mapping[str, Any]
) -> ConfigFlowResult:
"""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()