def create(self, request, *args, **kwargs): serializer = self.get_serializer(data=request.data) serializer.is_valid(raise_exception=True) user = serializer.save() if 'private_email' in serializer.validated_data: user.origin = 4 if 'mobile' in serializer.validated_data: user.origin = 3 user.save() cli = CLI(user) cli.add_users_to_group([user], Group.get_extern_root()) data = self.read_serializer_class(user).data data.update(token=user.token) return Response(data, status=status.HTTP_201_CREATED)
def create(self, request, *args, **kwargs): ''' qq扫码加绑定 ''' if not AccountConfig.get_current().support_qq_qr_register: return Response({'err_msg': 'qq qr register not allowed'}, HTTP_403_FORBIDDEN) serializer = self.get_serializer(data=request.data) serializer.is_valid(raise_exception=True) user = self.perform_create(serializer) cli = CLI(user) cli.add_users_to_group([user], Group.get_extern_root()) data = self.read_serializer_class(user).data data.update(token=user.token) open_id = serializer.validated_data['user_id'] qq_user = QQUser.valid_objects.create(open_id=open_id, user=user) qq_user.save() return Response(data, status=status.HTTP_201_CREATED)