mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 00:37:53 +00:00
Use new reauth helpers in verisure (#128778)
This commit is contained in:
parent
fd8f5b9ff0
commit
990987ac92
@ -3,7 +3,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Mapping
|
||||
from typing import Any, cast
|
||||
from typing import Any
|
||||
|
||||
from verisure import (
|
||||
Error as VerisureError,
|
||||
@ -38,7 +38,6 @@ class VerisureConfigFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
VERSION = 2
|
||||
|
||||
email: str
|
||||
entry: ConfigEntry
|
||||
password: str
|
||||
verisure: Verisure
|
||||
|
||||
@ -179,10 +178,6 @@ class VerisureConfigFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
self, entry_data: Mapping[str, Any]
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle initiation of re-authentication with Verisure."""
|
||||
self.entry = cast(
|
||||
ConfigEntry,
|
||||
self.hass.config_entries.async_get_entry(self.context["entry_id"]),
|
||||
)
|
||||
return await self.async_step_reauth_confirm()
|
||||
|
||||
async def async_step_reauth_confirm(
|
||||
@ -230,25 +225,21 @@ class VerisureConfigFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
LOGGER.debug("Unexpected response from Verisure, %s", ex)
|
||||
errors["base"] = "unknown"
|
||||
else:
|
||||
data = self.entry.data.copy()
|
||||
self.hass.config_entries.async_update_entry(
|
||||
self.entry,
|
||||
data={
|
||||
**data,
|
||||
return self.async_update_reload_and_abort(
|
||||
self._get_reauth_entry(),
|
||||
data_updates={
|
||||
CONF_EMAIL: user_input[CONF_EMAIL],
|
||||
CONF_PASSWORD: user_input[CONF_PASSWORD],
|
||||
},
|
||||
)
|
||||
self.hass.async_create_task(
|
||||
self.hass.config_entries.async_reload(self.entry.entry_id)
|
||||
)
|
||||
return self.async_abort(reason="reauth_successful")
|
||||
|
||||
return self.async_show_form(
|
||||
step_id="reauth_confirm",
|
||||
data_schema=vol.Schema(
|
||||
{
|
||||
vol.Required(CONF_EMAIL, default=self.entry.data[CONF_EMAIL]): str,
|
||||
vol.Required(
|
||||
CONF_EMAIL, default=self._get_reauth_entry().data[CONF_EMAIL]
|
||||
): str,
|
||||
vol.Required(CONF_PASSWORD): str,
|
||||
}
|
||||
),
|
||||
@ -274,18 +265,13 @@ class VerisureConfigFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
LOGGER.debug("Unexpected response from Verisure, %s", ex)
|
||||
errors["base"] = "unknown"
|
||||
else:
|
||||
self.hass.config_entries.async_update_entry(
|
||||
self.entry,
|
||||
data={
|
||||
**self.entry.data,
|
||||
return self.async_update_reload_and_abort(
|
||||
self._get_reauth_entry(),
|
||||
data_updates={
|
||||
CONF_EMAIL: self.email,
|
||||
CONF_PASSWORD: self.password,
|
||||
},
|
||||
)
|
||||
self.hass.async_create_task(
|
||||
self.hass.config_entries.async_reload(self.entry.entry_id)
|
||||
)
|
||||
return self.async_abort(reason="reauth_successful")
|
||||
|
||||
return self.async_show_form(
|
||||
step_id="reauth_mfa",
|
||||
|
Loading…
x
Reference in New Issue
Block a user