Exemplo n.º 1
0
 def create(self, request, *args, **kwargs):
     serializer = self.serializer_class(data=request.data)
     serializer.is_valid(raise_exception=True)
     user = serializer.save(request)
     token = jwt_encode(user)
     return Response(get_data_response(self.JWT_serializer_class, token,
                                       status.HTTP_200_OK),
                     status=status.HTTP_201_CREATED)
Exemplo n.º 2
0
    def perform_create(self, serializer):
        user = serializer.save(self.request)
        if getattr(settings, 'REST_USE_JWT', False):
            self.token = jwt_encode(user)
        else:
            create_token(self.token_model, user, serializer)

        complete_signup(self.request._request, user,
                        allauth_settings.EMAIL_VERIFICATION,
                        None)
        return user
Exemplo n.º 3
0
 def post(self, request, *args, **kwargs):
     serializer = self.serializer_class(data=request.data,
                                        context={'request': request})
     if serializer.is_valid(raise_exception=True):
         user = serializer.validated_data['user']
         token = jwt_encode(user)
         # Django Login function
         login(request, user)
         return Response(get_data_response(self.JWT_serializer_class, token,
                                           status.HTTP_200_OK),
                         status=status.HTTP_201_CREATED)
Exemplo n.º 4
0
 def create(self, request, *args, **kwargs):
     serializer = self.serializer_class(data=request.data)
     serializer.is_valid(raise_exception=True)
     user = serializer.save(request)
     token = jwt_encode(user)
     try:
         login(request, user)
     except (AttributeError, ObjectDoesNotExist):
         pass
     return Response(get_data_response(self.JWT_serializer_class, token,
                                       status.HTTP_200_OK),
                     status=status.HTTP_201_CREATED)
Exemplo n.º 5
0
 def login(self):
     self.user = self.serializer.validated_data['user']
     self.token = jwt_encode(self.user)
     login(self.request, self.user)