From 92943f08d9256b6125a5d0d37af61d40b323a0dc Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sat, 27 Feb 2021 16:29:36 +0100 Subject: [PATCH] sources/ldap: fix API error when source has not synced yet --- authentik/sources/ldap/api.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/authentik/sources/ldap/api.py b/authentik/sources/ldap/api.py index abe9e8c82..60551bc85 100644 --- a/authentik/sources/ldap/api.py +++ b/authentik/sources/ldap/api.py @@ -1,5 +1,6 @@ """Source API Views""" from datetime import datetime +from time import time from django.core.cache import cache from django.db.models.base import Model @@ -68,7 +69,7 @@ class LDAPSourceViewSet(ModelViewSet): def sync_status(self, request: Request, slug: str) -> Response: """Get source's sync status""" source = self.get_object() - last_sync = cache.get(source.state_cache_prefix("last_sync"), None) + last_sync = cache.get(source.state_cache_prefix("last_sync"), time()) return Response( LDAPSourceSyncStatusSerializer( {"last_sync": datetime.fromtimestamp(last_sync)}