mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 22:27:07 +00:00
Use new reauth helpers in transmission (#128765)
This commit is contained in:
parent
76712439ee
commit
46fa9e6b82
@ -55,7 +55,6 @@ class TransmissionFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
MINOR_VERSION = 2
|
MINOR_VERSION = 2
|
||||||
_reauth_entry: ConfigEntry | None
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@callback
|
@callback
|
||||||
@ -100,9 +99,6 @@ class TransmissionFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
self, entry_data: Mapping[str, Any]
|
self, entry_data: Mapping[str, Any]
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Perform reauth upon an API authentication error."""
|
"""Perform reauth upon an API authentication error."""
|
||||||
self._reauth_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(
|
||||||
@ -110,9 +106,9 @@ class TransmissionFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Confirm reauth dialog."""
|
"""Confirm reauth dialog."""
|
||||||
errors = {}
|
errors = {}
|
||||||
assert self._reauth_entry
|
reauth_entry = self._get_reauth_entry()
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
user_input = {**self._reauth_entry.data, **user_input}
|
user_input = {**reauth_entry.data, **user_input}
|
||||||
try:
|
try:
|
||||||
await get_api(self.hass, user_input)
|
await get_api(self.hass, user_input)
|
||||||
|
|
||||||
@ -121,16 +117,10 @@ class TransmissionFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
except (CannotConnect, UnknownError):
|
except (CannotConnect, UnknownError):
|
||||||
errors["base"] = "cannot_connect"
|
errors["base"] = "cannot_connect"
|
||||||
else:
|
else:
|
||||||
self.hass.config_entries.async_update_entry(
|
return self.async_update_reload_and_abort(reauth_entry, data=user_input)
|
||||||
self._reauth_entry, data=user_input
|
|
||||||
)
|
|
||||||
await self.hass.config_entries.async_reload(self._reauth_entry.entry_id)
|
|
||||||
return self.async_abort(reason="reauth_successful")
|
|
||||||
|
|
||||||
return self.async_show_form(
|
return self.async_show_form(
|
||||||
description_placeholders={
|
description_placeholders={CONF_USERNAME: reauth_entry.data[CONF_USERNAME]},
|
||||||
CONF_USERNAME: self._reauth_entry.data[CONF_USERNAME]
|
|
||||||
},
|
|
||||||
step_id="reauth_confirm",
|
step_id="reauth_confirm",
|
||||||
data_schema=vol.Schema(
|
data_schema=vol.Schema(
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user