HubAuth: allow caching None responses

when a token doesn't identify a user, the response is None.
These results are cached, but the cache checked for `is None`,
causing failed-auth responses to effectively not be cached.
This commit is contained in:
Min RK
2018-11-12 12:56:22 +01:00
parent 40013f7292
commit 3a0bacde3a

View File

@@ -277,11 +277,10 @@ class HubAuth(SingletonConfigurable):
if cache_key is None:
raise ValueError("cache_key is required when using cache")
# check for a cached reply, so we don't check with the Hub if we don't have to
cached = self.cache.get(cache_key)
if cached is not None:
return cached
else:
app_log.debug("Cache miss: %s" % cache_key)
try:
return self.cache[cache_key]
except KeyError:
app_log.debug("HubAuth cache miss: %s", cache_key)
data = self._api_request('GET', url, allow_404=True)
if data is None: