tenants: avoid extra queries in get_current_tenant (#8367)

Signed-off-by: Marc 'risson' Schmitt <marc.schmitt@risson.space>
This commit is contained in:
Marc 'risson' Schmitt
2024-01-30 13:09:17 +01:00
committed by GitHub
parent be6c29d907
commit c332f6f0ec

View File

@ -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)