From 43569727f4dd0891636a01c851b8e3d5a92b0cfd Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Wed, 2 Sep 2020 12:54:27 +0300 Subject: [PATCH] Signup: send a signal on account signup. --- django_etebase/serializers.py | 1 - django_etebase/signals.py | 3 +++ django_etebase/views.py | 3 +++ 3 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 django_etebase/signals.py diff --git a/django_etebase/serializers.py b/django_etebase/serializers.py index babf7d0..35b3562 100644 --- a/django_etebase/serializers.py +++ b/django_etebase/serializers.py @@ -462,7 +462,6 @@ class AuthenticationSignupSerializer(BetterErrorsMixin, serializers.Serializer): instance.clean_fields() except django_exceptions.ValidationError as e: self.transform_validation_error("user", e) - # FIXME: send email verification models.UserInfo.objects.create(**validated_data, owner=instance) diff --git a/django_etebase/signals.py b/django_etebase/signals.py new file mode 100644 index 0000000..03dbed5 --- /dev/null +++ b/django_etebase/signals.py @@ -0,0 +1,3 @@ +from django.dispatch import Signal + +user_signed_up = Signal(providing_args=['request', 'user']) diff --git a/django_etebase/views.py b/django_etebase/views.py index c8a98fc..97cb2f0 100644 --- a/django_etebase/views.py +++ b/django_etebase/views.py @@ -74,6 +74,7 @@ from .serializers import ( from .utils import get_user_queryset from .exceptions import EtebaseValidationError from .parsers import ChunkUploadParser +from .signals import user_signed_up User = get_user_model() @@ -646,6 +647,8 @@ class AuthenticationViewSet(viewsets.ViewSet): serializer.is_valid(raise_exception=True) user = serializer.save() + user_signed_up.send(sender=user.__class__, request=request, user=user) + data = self.login_response_data(user) return Response(data, status=status.HTTP_201_CREATED)