Signup: send a signal on account signup.

master
Tom Hacohen 4 years ago
parent 42a72ce5c7
commit 43569727f4

@ -462,7 +462,6 @@ class AuthenticationSignupSerializer(BetterErrorsMixin, serializers.Serializer):
instance.clean_fields() instance.clean_fields()
except django_exceptions.ValidationError as e: except django_exceptions.ValidationError as e:
self.transform_validation_error("user", e) self.transform_validation_error("user", e)
# FIXME: send email verification
models.UserInfo.objects.create(**validated_data, owner=instance) models.UserInfo.objects.create(**validated_data, owner=instance)

@ -0,0 +1,3 @@
from django.dispatch import Signal
user_signed_up = Signal(providing_args=['request', 'user'])

@ -74,6 +74,7 @@ from .serializers import (
from .utils import get_user_queryset from .utils import get_user_queryset
from .exceptions import EtebaseValidationError from .exceptions import EtebaseValidationError
from .parsers import ChunkUploadParser from .parsers import ChunkUploadParser
from .signals import user_signed_up
User = get_user_model() User = get_user_model()
@ -646,6 +647,8 @@ class AuthenticationViewSet(viewsets.ViewSet):
serializer.is_valid(raise_exception=True) serializer.is_valid(raise_exception=True)
user = serializer.save() user = serializer.save()
user_signed_up.send(sender=user.__class__, request=request, user=user)
data = self.login_response_data(user) data = self.login_response_data(user)
return Response(data, status=status.HTTP_201_CREATED) return Response(data, status=status.HTTP_201_CREATED)

Loading…
Cancel
Save