From a1c1c3a27c731cead4b96fe30facf568c72e10bc Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Wed, 15 Mar 2023 13:02:20 +0100 Subject: [PATCH] fix lint Signed-off-by: Jens Langhammer --- authentik/core/models.py | 2 +- authentik/core/views/apps.py | 1 + authentik/flows/views/executor.py | 4 ++-- authentik/tenants/utils.py | 2 -- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/authentik/core/models.py b/authentik/core/models.py index 715be3443..8b20202a7 100644 --- a/authentik/core/models.py +++ b/authentik/core/models.py @@ -228,7 +228,7 @@ class User(SerializerModel, GuardianUserMixin, AbstractUser): except Exception as exc: LOGGER.warning("Failed to get default locale", exc=exc) if request: - return get_tenant(request).locale + return get_tenant(request).default_locale return "" @property diff --git a/authentik/core/views/apps.py b/authentik/core/views/apps.py index 0dfe14f92..1f6ea8b12 100644 --- a/authentik/core/views/apps.py +++ b/authentik/core/views/apps.py @@ -26,6 +26,7 @@ from authentik.stages.consent.stage import ( PLAN_CONTEXT_CONSENT_HEADER, PLAN_CONTEXT_CONSENT_PERMISSIONS, ) +from authentik.tenants.utils import get_tenant class RedirectToAppLaunch(View): diff --git a/authentik/flows/views/executor.py b/authentik/flows/views/executor.py index 6332ada14..0577f6ad5 100644 --- a/authentik/flows/views/executor.py +++ b/authentik/flows/views/executor.py @@ -60,7 +60,7 @@ from authentik.lib.utils.errors import exception_to_string from authentik.lib.utils.reflection import all_subclasses, class_to_path from authentik.lib.utils.urls import is_url_absolute, redirect_with_qs from authentik.policies.engine import PolicyEngine -from authentik.tenants.models import Tenant +from authentik.tenants.utils import get_tenant LOGGER = get_logger() # Argument used to redirect user after login @@ -481,7 +481,7 @@ class ToDefaultFlow(View): def get_flow(self) -> Flow: """Get a flow for the selected designation""" - tenant: Tenant = self.request.tenant + tenant = get_tenant(self.request) flow = None # First, attempt to get default flow from tenant if self.designation == FlowDesignation.AUTHENTICATION: diff --git a/authentik/tenants/utils.py b/authentik/tenants/utils.py index 1e176ae2d..88f17542b 100644 --- a/authentik/tenants/utils.py +++ b/authentik/tenants/utils.py @@ -40,8 +40,6 @@ def get_tenant(request: HttpRequest | Request) -> "Tenant": def lookup_tenant_for_request(request: HttpRequest) -> "Tenant": """Get tenant object for current request""" - from authentik.tenants.models import Tenant - db_tenants = ( Tenant.objects.annotate(host_domain=V(request.get_host())) .filter(Q(host_domain__iendswith=F("domain")) | _q_default)