mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 00:37:53 +00:00
Use reauth helpers in permobil config flow (#127530)
This commit is contained in:
parent
563de82707
commit
d99429463b
@ -14,7 +14,7 @@ from mypermobil import (
|
||||
)
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.config_entries import SOURCE_REAUTH, ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.const import CONF_CODE, CONF_EMAIL, CONF_REGION, CONF_TOKEN, CONF_TTL
|
||||
from homeassistant.core import HomeAssistant, async_get_hass
|
||||
from homeassistant.helpers import selector
|
||||
@ -158,6 +158,11 @@ class PermobilConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
description_placeholders={"app_name": "MyPermobil"},
|
||||
)
|
||||
|
||||
if self.source == SOURCE_REAUTH:
|
||||
return self.async_update_reload_and_abort(
|
||||
self._get_reauth_entry(), title=self.data[CONF_EMAIL], data=self.data
|
||||
)
|
||||
|
||||
return self.async_create_entry(title=self.data[CONF_EMAIL], data=self.data)
|
||||
|
||||
async def async_step_reauth(
|
||||
|
@ -20,7 +20,8 @@
|
||||
}
|
||||
},
|
||||
"abort": {
|
||||
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]"
|
||||
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]",
|
||||
"reauth_successful": "[%key:common::config_flow::abort::reauth_successful%]"
|
||||
},
|
||||
"error": {
|
||||
"unknown": "Unexpected error, more information in the logs",
|
||||
|
@ -294,14 +294,15 @@ async def test_config_flow_reauth_success(
|
||||
assert result["step_id"] == "email_code"
|
||||
assert result["errors"] == {}
|
||||
|
||||
# request request new token
|
||||
# request new token
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
user_input={CONF_CODE: reauth_code},
|
||||
)
|
||||
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["data"] == {
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "reauth_successful"
|
||||
assert mock_entry.data == {
|
||||
CONF_EMAIL: MOCK_EMAIL,
|
||||
CONF_REGION: MOCK_URL,
|
||||
CONF_CODE: reauth_code,
|
||||
|
Loading…
x
Reference in New Issue
Block a user