From 9d50efd61db3df9e888fb4d4442619fe315b9e86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20W=C3=B3jcik?= Date: Wed, 22 May 2024 08:21:35 +0200 Subject: [PATCH] Create default tenant for newly created social users --- packages/backend/apps/multitenancy/pipeline.py | 6 ++++++ packages/backend/config/settings.py | 1 + 2 files changed, 7 insertions(+) create mode 100644 packages/backend/apps/multitenancy/pipeline.py diff --git a/packages/backend/apps/multitenancy/pipeline.py b/packages/backend/apps/multitenancy/pipeline.py new file mode 100644 index 000000000..931494e73 --- /dev/null +++ b/packages/backend/apps/multitenancy/pipeline.py @@ -0,0 +1,6 @@ +from .models import Tenant + + +def create_default_tenant(user=None, is_new=False, *args, **kwargs): + if user and is_new: + Tenant.objects.get_or_create_user_default_tenant(user) diff --git a/packages/backend/config/settings.py b/packages/backend/config/settings.py index a01b55d5e..fa2413bed 100644 --- a/packages/backend/config/settings.py +++ b/packages/backend/config/settings.py @@ -278,6 +278,7 @@ 'social_core.pipeline.user.create_user', 'social_core.pipeline.social_auth.associate_user', 'social_core.pipeline.social_auth.load_extra_data', + 'apps.multitenancy.pipeline.create_default_tenant', 'social_core.pipeline.user.user_details', ) SOCIAL_AUTH_ALLOWED_REDIRECT_HOSTS = env.list('SOCIAL_AUTH_ALLOWED_REDIRECT_HOSTS', default=[])