From 0df39b4df57be3681e041a5fd4e7f905fa567902 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Sat, 28 Nov 2015 18:32:15 -0800 Subject: [PATCH] Remove no password set boolean --- homeassistant/components/frontend/__init__.py | 2 +- homeassistant/components/http.py | 14 ++++---------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/homeassistant/components/frontend/__init__.py b/homeassistant/components/frontend/__init__.py index 9bc46f86023..dac2041fa56 100644 --- a/homeassistant/components/frontend/__init__.py +++ b/homeassistant/components/frontend/__init__.py @@ -65,7 +65,7 @@ def _handle_get_root(handler, path_match, data): app_url = "frontend-{}.html".format(version.VERSION) # auto login if no password was set, else check api_password param - auth = ('no_password_set' if handler.server.no_password_set + auth = ('no_password_set' if handler.server.api_password is None else data.get('api_password', '')) with open(INDEX_PATH) as template_file: diff --git a/homeassistant/components/http.py b/homeassistant/components/http.py index 33290a159fa..5e8332e283a 100644 --- a/homeassistant/components/http.py +++ b/homeassistant/components/http.py @@ -53,10 +53,6 @@ def setup(hass, config): conf = config[DOMAIN] api_password = util.convert(conf.get(CONF_API_PASSWORD), str) - no_password_set = api_password is None - - if no_password_set: - api_password = util.get_random_string() # If no server host is given, accept all incoming requests server_host = conf.get(CONF_SERVER_HOST, '0.0.0.0') @@ -66,7 +62,7 @@ def setup(hass, config): try: server = HomeAssistantHTTPServer( (server_host, server_port), RequestHandler, hass, api_password, - development, no_password_set) + development) except OSError: # If address already in use _LOGGER.exception("Error setting up HTTP server") @@ -93,14 +89,13 @@ class HomeAssistantHTTPServer(ThreadingMixIn, HTTPServer): # pylint: disable=too-many-arguments def __init__(self, server_address, request_handler_class, - hass, api_password, development, no_password_set): + hass, api_password, development): super().__init__(server_address, request_handler_class) self.server_address = server_address self.hass = hass self.api_password = api_password self.development = development - self.no_password_set = no_password_set self.paths = [] self.sessions = SessionStore() @@ -157,7 +152,7 @@ class RequestHandler(SimpleHTTPRequestHandler): def log_message(self, fmt, *arguments): """ Redirect built-in log to HA logging """ - if self.server.no_password_set: + if self.server.api_password is None: _LOGGER.info(fmt, *arguments) else: _LOGGER.info( @@ -192,8 +187,7 @@ class RequestHandler(SimpleHTTPRequestHandler): "Error parsing JSON", HTTP_UNPROCESSABLE_ENTITY) return - if self.server.no_password_set: - _LOGGER.warning('NO PASSWORD SET') + if self.server.api_password is None: self.authenticated = True elif HTTP_HEADER_HA_AUTH in self.headers: api_password = self.headers.get(HTTP_HEADER_HA_AUTH)