Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrored_repos
HomeAssistant
Core
Commits
d375dca1
Unverified
Commit
d375dca1
authored
5 months ago
by
epenet
Committed by
GitHub
5 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Use new reauth helpers in smarttub (#128743)
parent
5f04a623
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
homeassistant/components/smarttub/config_flow.py
+8
-26
8 additions, 26 deletions
homeassistant/components/smarttub/config_flow.py
with
8 additions
and
26 deletions
homeassistant/components/smarttub/config_flow.py
+
8
−
26
View file @
d375dca1
...
@@ -3,12 +3,12 @@
...
@@ -3,12 +3,12 @@
from
__future__
import
annotations
from
__future__
import
annotations
from
collections.abc
import
Mapping
from
collections.abc
import
Mapping
from
typing
import
TYPE_CHECKING
,
Any
from
typing
import
Any
from
smarttub
import
LoginFailed
from
smarttub
import
LoginFailed
import
voluptuous
as
vol
import
voluptuous
as
vol
from
homeassistant.config_entries
import
ConfigEntry
,
ConfigFlow
,
ConfigFlowResult
from
homeassistant.config_entries
import
SOURCE_REAUTH
,
ConfigFlow
,
ConfigFlowResult
from
homeassistant.const
import
CONF_EMAIL
,
CONF_PASSWORD
from
homeassistant.const
import
CONF_EMAIL
,
CONF_PASSWORD
from
.const
import
DOMAIN
from
.const
import
DOMAIN
...
@@ -24,12 +24,6 @@ class SmartTubConfigFlow(ConfigFlow, domain=DOMAIN):
...
@@ -24,12 +24,6 @@ class SmartTubConfigFlow(ConfigFlow, domain=DOMAIN):
VERSION
=
1
VERSION
=
1
def
__init__
(
self
)
->
None
:
"""
Instantiate config flow.
"""
super
().
__init__
()
self
.
_reauth_input
:
Mapping
[
str
,
Any
]
|
None
=
None
self
.
_reauth_entry
:
ConfigEntry
|
None
=
None
async
def
async_step_user
(
async
def
async_step_user
(
self
,
user_input
:
dict
[
str
,
Any
]
|
None
=
None
self
,
user_input
:
dict
[
str
,
Any
]
|
None
=
None
)
->
ConfigFlowResult
:
)
->
ConfigFlowResult
:
...
@@ -48,24 +42,17 @@ class SmartTubConfigFlow(ConfigFlow, domain=DOMAIN):
...
@@ -48,24 +42,17 @@ class SmartTubConfigFlow(ConfigFlow, domain=DOMAIN):
else
:
else
:
await
self
.
async_set_unique_id
(
account
.
id
)
await
self
.
async_set_unique_id
(
account
.
id
)
if
self
.
_reauth_input
is
None
:
if
self
.
source
!=
SOURCE_REAUTH
:
self
.
_abort_if_unique_id_configured
()
self
.
_abort_if_unique_id_configured
()
return
self
.
async_create_entry
(
return
self
.
async_create_entry
(
title
=
user_input
[
CONF_EMAIL
],
data
=
user_input
title
=
user_input
[
CONF_EMAIL
],
data
=
user_input
)
)
# this is a reauth attempt
# this is a reauth attempt
if
TYPE_CHECKING
:
self
.
_abort_if_unique_id_mismatch
(
reason
=
"
already_configured
"
)
assert
self
.
_reauth_entry
return
self
.
async_update_reload_and_abort
(
if
self
.
_reauth_entry
.
unique_id
!=
self
.
unique_id
:
self
.
_get_reauth_entry
(),
data
=
user_input
# there is a config entry matching this account,
# but it is not the one we were trying to reauth
return
self
.
async_abort
(
reason
=
"
already_configured
"
)
self
.
hass
.
config_entries
.
async_update_entry
(
self
.
_reauth_entry
,
data
=
user_input
)
)
await
self
.
hass
.
config_entries
.
async_reload
(
self
.
_reauth_entry
.
entry_id
)
return
self
.
async_abort
(
reason
=
"
reauth_successful
"
)
return
self
.
async_show_form
(
return
self
.
async_show_form
(
step_id
=
"
user
"
,
data_schema
=
DATA_SCHEMA
,
errors
=
errors
step_id
=
"
user
"
,
data_schema
=
DATA_SCHEMA
,
errors
=
errors
...
@@ -75,10 +62,6 @@ class SmartTubConfigFlow(ConfigFlow, domain=DOMAIN):
...
@@ -75,10 +62,6 @@ class SmartTubConfigFlow(ConfigFlow, domain=DOMAIN):
self
,
entry_data
:
Mapping
[
str
,
Any
]
self
,
entry_data
:
Mapping
[
str
,
Any
]
)
->
ConfigFlowResult
:
)
->
ConfigFlowResult
:
"""
Get new credentials if the current ones don
'
t work anymore.
"""
"""
Get new credentials if the current ones don
'
t work anymore.
"""
self
.
_reauth_input
=
entry_data
self
.
_reauth_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
(
...
@@ -86,13 +69,12 @@ class SmartTubConfigFlow(ConfigFlow, domain=DOMAIN):
...
@@ -86,13 +69,12 @@ class SmartTubConfigFlow(ConfigFlow, domain=DOMAIN):
)
->
ConfigFlowResult
:
)
->
ConfigFlowResult
:
"""
Dialog that informs the user that reauth is required.
"""
"""
Dialog that informs the user that reauth is required.
"""
if
user_input
is
None
:
if
user_input
is
None
:
if
TYPE_CHECKING
:
assert
self
.
_reauth_input
is
not
None
# same as DATA_SCHEMA but with default email
# same as DATA_SCHEMA but with default email
data_schema
=
vol
.
Schema
(
data_schema
=
vol
.
Schema
(
{
{
vol
.
Required
(
vol
.
Required
(
CONF_EMAIL
,
default
=
self
.
_reauth_input
.
get
(
CONF_EMAIL
)
CONF_EMAIL
,
default
=
self
.
_get_reauth_entry
().
data
.
get
(
CONF_EMAIL
),
):
str
,
):
str
,
vol
.
Required
(
CONF_PASSWORD
):
str
,
vol
.
Required
(
CONF_PASSWORD
):
str
,
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment