From 5ed3e879a225d27fca7eb6fe7e0695d2583b382e Mon Sep 17 00:00:00 2001 From: "gcp-cherry-pick-bot[bot]" <98988430+gcp-cherry-pick-bot[bot]@users.noreply.github.com> Date: Mon, 26 Feb 2024 18:59:18 +0100 Subject: [PATCH] enterprise: fix read_only activating when no license is installed (cherry-pick #8697) (#8698) enterprise: fix read_only activating when no license is installed (#8697) Signed-off-by: Jens Langhammer Co-authored-by: Jens L --- authentik/enterprise/license.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/authentik/enterprise/license.py b/authentik/enterprise/license.py index 7baa1b378a..88f22e5a7c 100644 --- a/authentik/enterprise/license.py +++ b/authentik/enterprise/license.py @@ -188,20 +188,21 @@ class LicenseKey: def summary(self) -> LicenseSummary: """Summary of license status""" + has_license = License.objects.all().count() > 0 last_valid = LicenseKey.last_valid_date() show_admin_warning = last_valid < now() - timedelta(weeks=2) show_user_warning = last_valid < now() - timedelta(weeks=4) read_only = last_valid < now() - timedelta(weeks=6) latest_valid = datetime.fromtimestamp(self.exp) return LicenseSummary( - show_admin_warning=show_admin_warning, - show_user_warning=show_user_warning, - read_only=read_only, + show_admin_warning=show_admin_warning and has_license, + show_user_warning=show_user_warning and has_license, + read_only=read_only and has_license, latest_valid=latest_valid, internal_users=self.internal_users, external_users=self.external_users, valid=self.is_valid(), - has_license=License.objects.all().count() > 0, + has_license=has_license, ) @staticmethod