From 84f791220ecfd795dc76ca4c67f0402e052b2287 Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Tue, 16 Oct 2018 12:30:24 +0200 Subject: [PATCH] Don't clean cache on fake auth (#765) * Don't clean cache on fake auth * Update auth.py --- hassio/auth.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hassio/auth.py b/hassio/auth.py index dc91d2c29..dc1d57f68 100644 --- a/hassio/auth.py +++ b/hassio/auth.py @@ -43,9 +43,13 @@ class Auth(JsonConfig, CoreSysAttributes): self._data[username_h] = password_h self.save_data() - def _dismatch_cache(self, username): + def _dismatch_cache(self, username, password): """Remove user from cache.""" username_h = _rehash(username) + password_h = _rehash(password, username) + + if self._data.get(username_h) =! password_h: + return self._data.pop(username_h, None) self.save_data() @@ -76,7 +80,7 @@ class Auth(JsonConfig, CoreSysAttributes): return True _LOGGER.warning("Wrong login from %s", username) - self._dismatch_cache(username) + self._dismatch_cache(username, password) return False except HomeAssistantAPIError: _LOGGER.error("Can't request auth on Home Assistant!")