Don't clean cache on fake auth (#765)

* Don't clean cache on fake auth

* Update auth.py
This commit is contained in:
Pascal Vizeli 2018-10-16 12:30:24 +02:00 committed by GitHub
parent cee2c5469f
commit 84f791220e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -43,9 +43,13 @@ class Auth(JsonConfig, CoreSysAttributes):
self._data[username_h] = password_h self._data[username_h] = password_h
self.save_data() self.save_data()
def _dismatch_cache(self, username): def _dismatch_cache(self, username, password):
"""Remove user from cache.""" """Remove user from cache."""
username_h = _rehash(username) 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._data.pop(username_h, None)
self.save_data() self.save_data()
@ -76,7 +80,7 @@ class Auth(JsonConfig, CoreSysAttributes):
return True return True
_LOGGER.warning("Wrong login from %s", username) _LOGGER.warning("Wrong login from %s", username)
self._dismatch_cache(username) self._dismatch_cache(username, password)
return False return False
except HomeAssistantAPIError: except HomeAssistantAPIError:
_LOGGER.error("Can't request auth on Home Assistant!") _LOGGER.error("Can't request auth on Home Assistant!")