From 392848c88522f2a777247bf9136ffc853a53d3ad Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Sat, 19 Oct 2024 09:16:06 +0200 Subject: [PATCH] Use reauth_confirm in myuplink (#128697) --- homeassistant/components/myuplink/config_flow.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/homeassistant/components/myuplink/config_flow.py b/homeassistant/components/myuplink/config_flow.py index fe31dcc6183..554347cfd19 100644 --- a/homeassistant/components/myuplink/config_flow.py +++ b/homeassistant/components/myuplink/config_flow.py @@ -4,7 +4,7 @@ from collections.abc import Mapping import logging from typing import Any -from homeassistant.config_entries import ConfigEntry, ConfigFlowResult +from homeassistant.config_entries import SOURCE_REAUTH, ConfigFlowResult from homeassistant.helpers import config_entry_oauth2_flow from .const import DOMAIN, OAUTH2_SCOPES @@ -17,8 +17,6 @@ class OAuth2FlowHandler( DOMAIN = DOMAIN - config_entry_reauth: ConfigEntry | None = None - @property def logger(self) -> logging.Logger: """Return logger.""" @@ -33,9 +31,6 @@ class OAuth2FlowHandler( self, entry_data: Mapping[str, Any] ) -> ConfigFlowResult: """Perform reauth upon an API authentication error.""" - self.config_entry_reauth = self.hass.config_entries.async_get_entry( - self.context["entry_id"] - ) return await self.async_step_reauth_confirm() async def async_step_reauth_confirm( @@ -51,9 +46,8 @@ class OAuth2FlowHandler( async def async_oauth_create_entry(self, data: dict) -> ConfigFlowResult: """Create or update the config entry.""" - if self.config_entry_reauth: + if self.source == SOURCE_REAUTH: return self.async_update_reload_and_abort( - self.config_entry_reauth, - data=data, + self._get_reauth_entry(), data=data ) return await super().async_oauth_create_entry(data)