Use reauth helpers in linear_garage_door (#128658)
This commit is contained in:
parent
f3f6cb03e6
commit
47b809c7b7
1 changed files with 8 additions and 12 deletions
|
@ -11,7 +11,7 @@ from linear_garage_door import Linear
|
||||||
from linear_garage_door.errors import InvalidLoginError
|
from linear_garage_door.errors import InvalidLoginError
|
||||||
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.const import CONF_EMAIL, CONF_PASSWORD
|
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
|
@ -69,7 +69,6 @@ class LinearGarageDoorConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
"""Initialize the config flow."""
|
"""Initialize the config flow."""
|
||||||
self.data: dict[str, Sequence[Collection[str]]] = {}
|
self.data: dict[str, Sequence[Collection[str]]] = {}
|
||||||
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
|
||||||
|
@ -93,14 +92,14 @@ class LinearGarageDoorConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
self.data = info
|
self.data = 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,
|
self._get_reauth_entry(),
|
||||||
data=self._reauth_entry.data
|
data_updates={
|
||||||
| {"email": self.data["email"], "password": self.data["password"]},
|
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()
|
return await self.async_step_site()
|
||||||
|
|
||||||
|
@ -150,9 +149,6 @@ class LinearGarageDoorConfigFlow(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…
Add table
Reference in a new issue