diff --git a/authentik/tenants/utils.py b/authentik/tenants/utils.py index aabc2e931f..0a7bf0c3e0 100644 --- a/authentik/tenants/utils.py +++ b/authentik/tenants/utils.py @@ -6,4 +6,7 @@ from authentik.tenants.models import Tenant def get_current_tenant() -> Tenant: """Get tenant for current request""" + tenant = getattr(connection, "tenant", None) + if tenant: + return tenant return Tenant.objects.get(schema_name=connection.schema_name)