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