Signup: don't try to clean fields for objects we haven't created.

master
Tom Hacohen 4 years ago
parent 9cad5d62e1
commit 24c161b0d8

@ -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

Loading…
Cancel
Save