mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 14:17:45 +00:00
Implement reauth_confirm in fireservicerota (#77487)
This commit is contained in:
parent
fee3898f64
commit
94e2646c87
@ -1,9 +1,15 @@
|
|||||||
"""Config flow for FireServiceRota."""
|
"""Config flow for FireServiceRota."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from collections.abc import Mapping
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
from pyfireservicerota import FireServiceRota, InvalidAuthError
|
from pyfireservicerota import FireServiceRota, InvalidAuthError
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant import config_entries
|
||||||
from homeassistant.const import CONF_PASSWORD, CONF_TOKEN, CONF_URL, CONF_USERNAME
|
from homeassistant.const import CONF_PASSWORD, CONF_TOKEN, CONF_URL, CONF_USERNAME
|
||||||
|
from homeassistant.data_entry_flow import FlowResult
|
||||||
|
|
||||||
from .const import DOMAIN, URL_LIST
|
from .const import DOMAIN, URL_LIST
|
||||||
|
|
||||||
@ -110,18 +116,18 @@ class FireServiceRotaFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
description_placeholders=self._description_placeholders,
|
description_placeholders=self._description_placeholders,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_step_reauth(self, user_input=None):
|
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
|
||||||
|
"""Initialise re-authentication."""
|
||||||
|
await self.async_set_unique_id(entry_data[CONF_USERNAME])
|
||||||
|
self._existing_entry = {**entry_data}
|
||||||
|
self._description_placeholders = {CONF_USERNAME: entry_data[CONF_USERNAME]}
|
||||||
|
return await self.async_step_reauth_confirm()
|
||||||
|
|
||||||
|
async def async_step_reauth_confirm(
|
||||||
|
self, user_input: dict[str, str] | None = None
|
||||||
|
) -> FlowResult:
|
||||||
"""Get new tokens for a config entry that can't authenticate."""
|
"""Get new tokens for a config entry that can't authenticate."""
|
||||||
|
|
||||||
if not self._existing_entry:
|
|
||||||
await self.async_set_unique_id(user_input[CONF_USERNAME])
|
|
||||||
self._existing_entry = user_input.copy()
|
|
||||||
self._description_placeholders = {"username": user_input[CONF_USERNAME]}
|
|
||||||
user_input = None
|
|
||||||
|
|
||||||
if user_input is None:
|
if user_input is None:
|
||||||
return self._show_setup_form(step_id=config_entries.SOURCE_REAUTH)
|
return self._show_setup_form(step_id="reauth_confirm")
|
||||||
|
|
||||||
return await self._validate_and_create_entry(
|
return await self._validate_and_create_entry(user_input, "reauth_confirm")
|
||||||
user_input, config_entries.SOURCE_REAUTH
|
|
||||||
)
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
"url": "Website"
|
"url": "Website"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"reauth": {
|
"reauth_confirm": {
|
||||||
"description": "Authentication tokens became invalid, login to recreate them.",
|
"description": "Authentication tokens became invalid, login to recreate them.",
|
||||||
"data": {
|
"data": {
|
||||||
"password": "[%key:common::config_flow::data::password%]"
|
"password": "[%key:common::config_flow::data::password%]"
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
"invalid_auth": "Invalid authentication"
|
"invalid_auth": "Invalid authentication"
|
||||||
},
|
},
|
||||||
"step": {
|
"step": {
|
||||||
"reauth": {
|
"reauth_confirm": {
|
||||||
"data": {
|
"data": {
|
||||||
"password": "Password"
|
"password": "Password"
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user