mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Use new reauth_helpers in nice_go (#128702)
This commit is contained in:
parent
a94968b6bb
commit
9a09c1b027
@ -5,7 +5,7 @@ from __future__ import annotations
|
||||
from collections.abc import Mapping
|
||||
from datetime import datetime
|
||||
import logging
|
||||
from typing import TYPE_CHECKING, Any
|
||||
from typing import Any
|
||||
|
||||
from nice_go import AuthFailedError, NiceGOApi
|
||||
import voluptuous as vol
|
||||
@ -14,7 +14,6 @@ from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.const import CONF_EMAIL, CONF_NAME, CONF_PASSWORD
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
|
||||
from . import NiceGOConfigEntry
|
||||
from .const import CONF_REFRESH_TOKEN, CONF_REFRESH_TOKEN_CREATION_TIME, DOMAIN
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
@ -31,7 +30,6 @@ class NiceGOConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a config flow for Nice G.O."""
|
||||
|
||||
VERSION = 1
|
||||
reauth_entry: NiceGOConfigEntry | None
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
@ -74,10 +72,6 @@ class NiceGOConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
self, entry_data: Mapping[str, Any]
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle re-authentication."""
|
||||
self.reauth_entry = self.hass.config_entries.async_get_entry(
|
||||
self.context["entry_id"]
|
||||
)
|
||||
|
||||
return await self.async_step_reauth_confirm()
|
||||
|
||||
async def async_step_reauth_confirm(
|
||||
@ -86,9 +80,7 @@ class NiceGOConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
"""Confirm re-authentication."""
|
||||
errors = {}
|
||||
|
||||
if TYPE_CHECKING:
|
||||
assert self.reauth_entry is not None
|
||||
|
||||
reauth_entry = self._get_reauth_entry()
|
||||
if user_input is not None:
|
||||
hub = NiceGOApi()
|
||||
|
||||
@ -105,7 +97,7 @@ class NiceGOConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
errors["base"] = "unknown"
|
||||
else:
|
||||
return self.async_update_reload_and_abort(
|
||||
self.reauth_entry,
|
||||
reauth_entry,
|
||||
data={
|
||||
**user_input,
|
||||
CONF_REFRESH_TOKEN: refresh_token,
|
||||
@ -118,8 +110,8 @@ class NiceGOConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
step_id="reauth_confirm",
|
||||
data_schema=self.add_suggested_values_to_schema(
|
||||
STEP_USER_DATA_SCHEMA,
|
||||
user_input or {CONF_EMAIL: self.reauth_entry.data[CONF_EMAIL]},
|
||||
user_input or {CONF_EMAIL: reauth_entry.data[CONF_EMAIL]},
|
||||
),
|
||||
description_placeholders={CONF_NAME: self.reauth_entry.title},
|
||||
description_placeholders={CONF_NAME: reauth_entry.title},
|
||||
errors=errors,
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user