mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 22:27:07 +00:00
Use new reauth helpers in teslemetry (#128759)
This commit is contained in:
parent
98732cb033
commit
b13e1b3d44
@ -14,7 +14,7 @@ from tesla_fleet_api.exceptions import (
|
|||||||
)
|
)
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_ACCESS_TOKEN
|
from homeassistant.const import CONF_ACCESS_TOKEN
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
|
|
||||||
@ -33,7 +33,6 @@ class TeslemetryConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
MINOR_VERSION = 2
|
MINOR_VERSION = 2
|
||||||
_entry: ConfigEntry | None = None
|
|
||||||
|
|
||||||
async def async_auth(self, user_input: Mapping[str, Any]) -> dict[str, str]:
|
async def async_auth(self, user_input: Mapping[str, Any]) -> dict[str, str]:
|
||||||
"""Reusable Auth Helper."""
|
"""Reusable Auth Helper."""
|
||||||
@ -79,7 +78,6 @@ class TeslemetryConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
self, entry_data: Mapping[str, Any]
|
self, entry_data: Mapping[str, Any]
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle reauth on failure."""
|
"""Handle reauth on failure."""
|
||||||
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(
|
||||||
@ -87,12 +85,11 @@ class TeslemetryConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle users reauth credentials."""
|
"""Handle users reauth credentials."""
|
||||||
|
|
||||||
assert self._entry
|
|
||||||
errors: dict[str, str] = {}
|
errors: dict[str, str] = {}
|
||||||
|
|
||||||
if user_input and not (errors := await self.async_auth(user_input)):
|
if user_input and not (errors := await self.async_auth(user_input)):
|
||||||
return self.async_update_reload_and_abort(
|
return self.async_update_reload_and_abort(
|
||||||
self._entry,
|
self._get_reauth_entry(),
|
||||||
data=user_input,
|
data=user_input,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user