mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Use new reauth helpers in yale_smart_alarm (#128836)
This commit is contained in:
parent
f01231277b
commit
6bfed5c98c
@ -40,7 +40,6 @@ DATA_SCHEMA = vol.Schema(
|
|||||||
|
|
||||||
DATA_SCHEMA_AUTH = vol.Schema(
|
DATA_SCHEMA_AUTH = vol.Schema(
|
||||||
{
|
{
|
||||||
vol.Required(CONF_USERNAME): cv.string,
|
|
||||||
vol.Required(CONF_PASSWORD): cv.string,
|
vol.Required(CONF_PASSWORD): cv.string,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@ -51,8 +50,6 @@ class YaleConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
|
|
||||||
VERSION = 2
|
VERSION = 2
|
||||||
|
|
||||||
entry: ConfigEntry | None
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@callback
|
@callback
|
||||||
def async_get_options_flow(config_entry: ConfigEntry) -> YaleOptionsFlowHandler:
|
def async_get_options_flow(config_entry: ConfigEntry) -> YaleOptionsFlowHandler:
|
||||||
@ -63,7 +60,6 @@ class YaleConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
self, entry_data: Mapping[str, Any]
|
self, entry_data: Mapping[str, Any]
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle initiation of re-authentication with Yale."""
|
"""Handle initiation of re-authentication with Yale."""
|
||||||
self.entry = 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(
|
||||||
@ -73,7 +69,8 @@ class YaleConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
errors = {}
|
errors = {}
|
||||||
|
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
username = user_input[CONF_USERNAME]
|
reauth_entry = self._get_reauth_entry()
|
||||||
|
username = reauth_entry.data[CONF_USERNAME]
|
||||||
password = user_input[CONF_PASSWORD]
|
password = user_input[CONF_PASSWORD]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -88,18 +85,10 @@ class YaleConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
errors = {"base": "cannot_connect"}
|
errors = {"base": "cannot_connect"}
|
||||||
|
|
||||||
if not errors:
|
if not errors:
|
||||||
existing_entry = await self.async_set_unique_id(username)
|
return self.async_update_reload_and_abort(
|
||||||
if existing_entry and self.entry:
|
reauth_entry,
|
||||||
self.hass.config_entries.async_update_entry(
|
data_updates={CONF_PASSWORD: password},
|
||||||
existing_entry,
|
|
||||||
data={
|
|
||||||
**self.entry.data,
|
|
||||||
CONF_USERNAME: username,
|
|
||||||
CONF_PASSWORD: password,
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
await self.hass.config_entries.async_reload(existing_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",
|
||||||
|
@ -19,10 +19,7 @@
|
|||||||
},
|
},
|
||||||
"reauth_confirm": {
|
"reauth_confirm": {
|
||||||
"data": {
|
"data": {
|
||||||
"username": "[%key:common::config_flow::data::username%]",
|
"password": "[%key:common::config_flow::data::password%]"
|
||||||
"password": "[%key:common::config_flow::data::password%]",
|
|
||||||
"name": "[%key:common::config_flow::data::name%]",
|
|
||||||
"area_id": "[%key:component::yale_smart_alarm::config::step::user::data::area_id%]"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -149,7 +149,6 @@ async def test_reauth_flow(hass: HomeAssistant) -> None:
|
|||||||
result2 = await hass.config_entries.flow.async_configure(
|
result2 = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
{
|
{
|
||||||
"username": "test-username",
|
|
||||||
"password": "new-test-password",
|
"password": "new-test-password",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@ -203,7 +202,6 @@ async def test_reauth_flow_error(
|
|||||||
result2 = await hass.config_entries.flow.async_configure(
|
result2 = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
{
|
{
|
||||||
"username": "test-username",
|
|
||||||
"password": "wrong-password",
|
"password": "wrong-password",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@ -226,7 +224,6 @@ async def test_reauth_flow_error(
|
|||||||
result2 = await hass.config_entries.flow.async_configure(
|
result2 = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
{
|
{
|
||||||
"username": "test-username",
|
|
||||||
"password": "new-test-password",
|
"password": "new-test-password",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user