Cloud cognito switch (#10823)
* Allow email based cognito instance * Fix quitting Home Assistant while reconnecting * Lint
This commit is contained in:
parent
1b7a64412d
commit
fe0a9529ed
5 changed files with 60 additions and 24 deletions
|
@ -69,7 +69,10 @@ def register(cloud, email, password):
|
|||
|
||||
cognito = _cognito(cloud)
|
||||
try:
|
||||
cognito.register(_generate_username(email), password, email=email)
|
||||
if cloud.cognito_email_based:
|
||||
cognito.register(email, password, email=email)
|
||||
else:
|
||||
cognito.register(_generate_username(email), password, email=email)
|
||||
except ClientError as err:
|
||||
raise _map_aws_exception(err)
|
||||
|
||||
|
@ -80,7 +83,11 @@ def confirm_register(cloud, confirmation_code, email):
|
|||
|
||||
cognito = _cognito(cloud)
|
||||
try:
|
||||
cognito.confirm_sign_up(confirmation_code, _generate_username(email))
|
||||
if cloud.cognito_email_based:
|
||||
cognito.confirm_sign_up(confirmation_code, email)
|
||||
else:
|
||||
cognito.confirm_sign_up(confirmation_code,
|
||||
_generate_username(email))
|
||||
except ClientError as err:
|
||||
raise _map_aws_exception(err)
|
||||
|
||||
|
@ -89,7 +96,11 @@ def forgot_password(cloud, email):
|
|||
"""Initiate forgotten password flow."""
|
||||
from botocore.exceptions import ClientError
|
||||
|
||||
cognito = _cognito(cloud, username=_generate_username(email))
|
||||
if cloud.cognito_email_based:
|
||||
cognito = _cognito(cloud, username=email)
|
||||
else:
|
||||
cognito = _cognito(cloud, username=_generate_username(email))
|
||||
|
||||
try:
|
||||
cognito.initiate_forgot_password()
|
||||
except ClientError as err:
|
||||
|
@ -100,7 +111,11 @@ def confirm_forgot_password(cloud, confirmation_code, email, new_password):
|
|||
"""Confirm forgotten password code and change password."""
|
||||
from botocore.exceptions import ClientError
|
||||
|
||||
cognito = _cognito(cloud, username=_generate_username(email))
|
||||
if cloud.cognito_email_based:
|
||||
cognito = _cognito(cloud, username=email)
|
||||
else:
|
||||
cognito = _cognito(cloud, username=_generate_username(email))
|
||||
|
||||
try:
|
||||
cognito.confirm_forgot_password(confirmation_code, new_password)
|
||||
except ClientError as err:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue