Use reauth helpers in linear_garage_door (#128658)
parent
f3f6cb03e6
commit
47b809c7b7
|
@ -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()
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue