mirror of
https://github.com/home-assistant/core.git
synced 2025-07-12 07:47:08 +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 __future__ import annotations
|
||||||
|
|
||||||
from collections.abc import Mapping
|
from collections.abc import Mapping
|
||||||
from typing import Any, cast
|
from typing import Any
|
||||||
|
|
||||||
from verisure import (
|
from verisure import (
|
||||||
Error as VerisureError,
|
Error as VerisureError,
|
||||||
@ -38,7 +38,6 @@ class VerisureConfigFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
VERSION = 2
|
VERSION = 2
|
||||||
|
|
||||||
email: str
|
email: str
|
||||||
entry: ConfigEntry
|
|
||||||
password: str
|
password: str
|
||||||
verisure: Verisure
|
verisure: Verisure
|
||||||
|
|
||||||
@ -179,10 +178,6 @@ class VerisureConfigFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
self, entry_data: Mapping[str, Any]
|
self, entry_data: Mapping[str, Any]
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle initiation of re-authentication with Verisure."""
|
"""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()
|
return await self.async_step_reauth_confirm()
|
||||||
|
|
||||||
async def 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)
|
LOGGER.debug("Unexpected response from Verisure, %s", ex)
|
||||||
errors["base"] = "unknown"
|
errors["base"] = "unknown"
|
||||||
else:
|
else:
|
||||||
data = self.entry.data.copy()
|
return self.async_update_reload_and_abort(
|
||||||
self.hass.config_entries.async_update_entry(
|
self._get_reauth_entry(),
|
||||||
self.entry,
|
data_updates={
|
||||||
data={
|
|
||||||
**data,
|
|
||||||
CONF_EMAIL: user_input[CONF_EMAIL],
|
CONF_EMAIL: user_input[CONF_EMAIL],
|
||||||
CONF_PASSWORD: user_input[CONF_PASSWORD],
|
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(
|
return self.async_show_form(
|
||||||
step_id="reauth_confirm",
|
step_id="reauth_confirm",
|
||||||
data_schema=vol.Schema(
|
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,
|
vol.Required(CONF_PASSWORD): str,
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
@ -274,18 +265,13 @@ class VerisureConfigFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
LOGGER.debug("Unexpected response from Verisure, %s", ex)
|
LOGGER.debug("Unexpected response from Verisure, %s", ex)
|
||||||
errors["base"] = "unknown"
|
errors["base"] = "unknown"
|
||||||
else:
|
else:
|
||||||
self.hass.config_entries.async_update_entry(
|
return self.async_update_reload_and_abort(
|
||||||
self.entry,
|
self._get_reauth_entry(),
|
||||||
data={
|
data_updates={
|
||||||
**self.entry.data,
|
|
||||||
CONF_EMAIL: self.email,
|
CONF_EMAIL: self.email,
|
||||||
CONF_PASSWORD: self.password,
|
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(
|
return self.async_show_form(
|
||||||
step_id="reauth_mfa",
|
step_id="reauth_mfa",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user