Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if not self.login:
_LOGGER.debug("Creating new login")
self.login = AlexaLogin(
self.config[CONF_URL],
self.config[CONF_EMAIL],
self.config[CONF_PASSWORD],
self.hass.config.path,
self.config[CONF_DEBUG],
)
await self.login.login_with_cookie()
return await self._test_login()
else:
_LOGGER.debug("Using existing login")
await self.login.login(data=user_input)
return await self._test_login()
except AlexapyConnectionError:
return await self._show_form(errors={"base": "connection_error"})
except BaseException as ex:
_LOGGER.warning("Unknown error: %s", ex)
return await self._show_form(errors={"base": "unknown_error"})
async def async_step_process(self, user_input=None):
"""Handle the input processing of the config flow."""
if user_input:
if CONF_PASSWORD in user_input:
password = user_input[CONF_PASSWORD]
self.config[CONF_PASSWORD] = password
try:
await self.login.login(data=user_input)
except AlexapyConnectionError:
return await self._show_form(
errors={"base": "connection_error"})
except BaseException as ex:
_LOGGER.warning("Unknown error: %s", ex)
return await self._show_form(errors={"base": "unknown_error"})
return await self._test_login()
if not self.login:
_LOGGER.debug("Creating new login")
self.login = AlexaLogin(
self.config[CONF_URL],
self.config[CONF_EMAIL],
self.config[CONF_PASSWORD],
self.hass.config.path,
self.config[CONF_DEBUG],
)
await self.login.login_with_cookie()
return await self._test_login()
else:
_LOGGER.debug("Using existing login")
await self.login.login(data=user_input)
return await self._test_login()
except AlexapyConnectionError:
return await self._show_form(errors={"base": "connection_error"})
except BaseException as ex:
_LOGGER.warning("Unknown error: %s", ex)
return await self._show_form(errors={"base": "unknown_error"})