mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +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
|
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.const import CONF_CODE, CONF_EMAIL, CONF_REGION, CONF_TOKEN, CONF_TTL
|
||||||
from homeassistant.core import HomeAssistant, async_get_hass
|
from homeassistant.core import HomeAssistant, async_get_hass
|
||||||
from homeassistant.helpers import selector
|
from homeassistant.helpers import selector
|
||||||
@ -158,6 +158,11 @@ class PermobilConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
description_placeholders={"app_name": "MyPermobil"},
|
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)
|
return self.async_create_entry(title=self.data[CONF_EMAIL], data=self.data)
|
||||||
|
|
||||||
async def async_step_reauth(
|
async def async_step_reauth(
|
||||||
|
@ -20,7 +20,8 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"abort": {
|
"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": {
|
"error": {
|
||||||
"unknown": "Unexpected error, more information in the logs",
|
"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["step_id"] == "email_code"
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
|
||||||
# request request new token
|
# request new token
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
user_input={CONF_CODE: reauth_code},
|
user_input={CONF_CODE: reauth_code},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["data"] == {
|
assert result["reason"] == "reauth_successful"
|
||||||
|
assert mock_entry.data == {
|
||||||
CONF_EMAIL: MOCK_EMAIL,
|
CONF_EMAIL: MOCK_EMAIL,
|
||||||
CONF_REGION: MOCK_URL,
|
CONF_REGION: MOCK_URL,
|
||||||
CONF_CODE: reauth_code,
|
CONF_CODE: reauth_code,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user