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)