From 4574e0058dac31f0377a5f7fc4024b9592cdba19 Mon Sep 17 00:00:00 2001 From: "Alan D. Tse" Date: Sat, 2 Jan 2021 01:25:59 -0800 Subject: [PATCH] fix: show login failure with error page detection Error page was incorrectly going to action required page. --- custom_components/alexa_media/config_flow.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/custom_components/alexa_media/config_flow.py b/custom_components/alexa_media/config_flow.py index b5289969..2a6a47cb 100644 --- a/custom_components/alexa_media/config_flow.py +++ b/custom_components/alexa_media/config_flow.py @@ -501,7 +501,11 @@ async def _test_login(self): step_id="verificationcode", data_schema=vol.Schema(self.verificationcode_schema), ) - if login.status and login.status.get("force_get"): + if ( + login.status + and login.status.get("force_get") + and not login.status.get("ap_error_href") + ): _LOGGER.debug("Creating config_flow to wait for user action") self.automatic_steps = 0 return self.async_show_form( @@ -513,13 +517,15 @@ async def _test_login(self): "message": f" \n>{login.status.get('message','')} \n", }, ) - if login.status and login.status.get("login_failed"): + if login.status and ( + login.status.get("login_failed") or login.status.get("ap_error_href") + ): _LOGGER.debug("Login failed: %s", login.status.get("login_failed")) await login.close() self.hass.components.persistent_notification.async_dismiss( "alexa_media_relogin_required" ) - return self.async_abort(reason=login.status.get("login_failed"),) + return self.async_abort(reason=login.status.get("login_failed")) new_schema = self._update_schema_defaults() if login.status and login.status.get("error_message"): _LOGGER.debug("Login error detected: %s", login.status.get("error_message"))