1
0
mirror of https://github.com/etesync/server synced 2024-12-29 02:38:07 +00:00

Signup: use the recommended drf style for validation.

This commit is contained in:
Tom Hacohen 2020-05-31 16:06:59 +03:00
parent 40db4e14b0
commit 6051a5ae3a

View File

@ -573,13 +573,11 @@ class AuthenticationViewSet(viewsets.ViewSet):
@action_decorator(detail=False, methods=['POST']) @action_decorator(detail=False, methods=['POST'])
def signup(self, request): def signup(self, request):
serializer = AuthenticationSignupSerializer(data=request.data) serializer = AuthenticationSignupSerializer(data=request.data)
if serializer.is_valid(): serializer.is_valid(raise_exception=True)
user = serializer.save() user = serializer.save()
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)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
def get_login_user(self, serializer): def get_login_user(self, serializer):
username = serializer.validated_data.get('username') username = serializer.validated_data.get('username')