From 24c161b0d84d59572ec342631416607ebc197e0e Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Tue, 13 Oct 2020 11:09:22 +0300 Subject: [PATCH] Signup: don't try to clean fields for objects we haven't created. --- django_etebase/serializers.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/django_etebase/serializers.py b/django_etebase/serializers.py index 4798f97..5cc24aa 100644 --- a/django_etebase/serializers.py +++ b/django_etebase/serializers.py @@ -462,19 +462,17 @@ class AuthenticationSignupSerializer(BetterErrorsMixin, serializers.Serializer): # Create the user and save the casing the user chose as the first name try: instance = create_user(**user_data, password=None, first_name=user_data['username'], view=view) + instance.clean_fields() except EtebaseValidationError as e: raise e + except django_exceptions.ValidationError as e: + self.transform_validation_error("user", e) except Exception as e: raise EtebaseValidationError('generic', str(e)) if hasattr(instance, 'userinfo'): raise EtebaseValidationError('user_exists', 'User already exists', status_code=status.HTTP_409_CONFLICT) - try: - instance.clean_fields() - except django_exceptions.ValidationError as e: - self.transform_validation_error("user", e) - models.UserInfo.objects.create(**validated_data, owner=instance) return instance