mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 12:47:08 +00:00
Use _get_reauth/reconfigure_entry in melcloud (#127302)
This commit is contained in:
parent
4d49cb2d18
commit
5a4cdaf348
@ -25,7 +25,7 @@ class FlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
"""Handle a config flow."""
|
"""Handle a config flow."""
|
||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
entry: ConfigEntry | None = None
|
entry: ConfigEntry
|
||||||
|
|
||||||
async def _create_entry(self, username: str, token: str) -> ConfigFlowResult:
|
async def _create_entry(self, username: str, token: str) -> ConfigFlowResult:
|
||||||
"""Register new entry."""
|
"""Register new entry."""
|
||||||
@ -82,7 +82,7 @@ class FlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
self, entry_data: Mapping[str, Any]
|
self, entry_data: Mapping[str, Any]
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle initiation of re-authentication with MELCloud."""
|
"""Handle initiation of re-authentication with MELCloud."""
|
||||||
self.entry = self.hass.config_entries.async_get_entry(self.context["entry_id"])
|
self.entry = self._get_reauth_entry()
|
||||||
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(
|
||||||
@ -91,7 +91,7 @@ class FlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
"""Handle re-authentication with MELCloud."""
|
"""Handle re-authentication with MELCloud."""
|
||||||
errors: dict[str, str] = {}
|
errors: dict[str, str] = {}
|
||||||
|
|
||||||
if user_input is not None and self.entry:
|
if user_input is not None:
|
||||||
aquired_token, errors = await self.async_reauthenticate_client(user_input)
|
aquired_token, errors = await self.async_reauthenticate_client(user_input)
|
||||||
|
|
||||||
if not errors:
|
if not errors:
|
||||||
@ -152,7 +152,7 @@ class FlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
self, entry_data: Mapping[str, Any]
|
self, entry_data: Mapping[str, Any]
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle a reconfiguration flow initialized by the user."""
|
"""Handle a reconfiguration flow initialized by the user."""
|
||||||
self.entry = self.hass.config_entries.async_get_entry(self.context["entry_id"])
|
self.entry = self._get_reconfigure_entry()
|
||||||
return await self.async_step_reconfigure_confirm()
|
return await self.async_step_reconfigure_confirm()
|
||||||
|
|
||||||
async def async_step_reconfigure_confirm(
|
async def async_step_reconfigure_confirm(
|
||||||
@ -161,7 +161,6 @@ class FlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
"""Handle a reconfiguration flow initialized by the user."""
|
"""Handle a reconfiguration flow initialized by the user."""
|
||||||
errors: dict[str, str] = {}
|
errors: dict[str, str] = {}
|
||||||
acquired_token = None
|
acquired_token = None
|
||||||
assert self.entry
|
|
||||||
|
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
user_input[CONF_USERNAME] = self.entry.data[CONF_USERNAME]
|
user_input[CONF_USERNAME] = self.entry.data[CONF_USERNAME]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user