Skip to content

Commit

Permalink
simplify
Browse files Browse the repository at this point in the history
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
  • Loading branch information
BeryJu committed Jan 31, 2024
1 parent abfdc51 commit 12cdcb6
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions authentik/tenants/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@
def get_current_tenant() -> Tenant:
"""Get tenant for current request"""
tenant = getattr(connection, "tenant", None)
if tenant:
# See https://github.com/django-tenants/django-tenants/blob/\
# master/django_tenants/postgresql_backend/base.py#L196
if isinstance(tenant, FakeTenant):
proper_tennat = Tenant.objects.get(schema_name=connection.schema_name)
setattr(connection, "tenant", proper_tennat)
return proper_tennat
# See https://github.com/django-tenants/django-tenants/blob/\
# master/django_tenants/postgresql_backend/base.py#L196
if not tenant or isinstance(tenant, FakeTenant):
tenant = Tenant.objects.get(schema_name=connection.schema_name)
setattr(connection, "tenant", tenant)
print(tenant, tenant.avatars)
return tenant
return Tenant.objects.get(schema_name=connection.schema_name)

0 comments on commit 12cdcb6

Please sign in to comment.