update registration views to work with simplejwt

This commit is contained in:
alichass 2020-03-11 06:05:11 -04:00
parent 4fb746e645
commit 23e88f9838

View File

@ -49,7 +49,8 @@ class RegisterView(CreateAPIView):
if getattr(settings, 'REST_USE_JWT', False):
data = {
'user': user,
'token': self.token
'access_token': self.access_token,
'refresh_token': self.refresh_token
}
return JWTSerializer(data).data
else:
@ -68,7 +69,7 @@ class RegisterView(CreateAPIView):
def perform_create(self, serializer):
user = serializer.save(self.request)
if getattr(settings, 'REST_USE_JWT', False):
self.token = jwt_encode(user)
self.access_token, self.refresh_token = jwt_encode(user)
else:
create_token(self.token_model, user, serializer)