Add as_serializer_error for consistent error messages

This commit is contained in:
Daniel Gilge 2018-11-21 10:41:00 +01:00 committed by GitHub
parent c0d3debe4c
commit 8f47bc9d14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -211,8 +211,10 @@ class RegisterSerializer(serializers.Serializer):
user = adapter.save_user(request, user, self, commit=False)
try:
adapter.clean_password(self.cleaned_data['password1'], user=user)
except DjangoValidationError as e:
raise serializers.ValidationError(e.messages)
except DjangoValidationError as exc:
raise serializers.ValidationError(
detail=serializers.as_serializer_error(exc)
)
user.save()
self.custom_signup(request, user)
setup_user_email(request, user, [])