Beispiel #1
0
    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)
Beispiel #2
0
 def inner(self, request):
     return Response({'err_msg': 'github not allowed'}, HTTP_403_FORBIDDEN)\
         if not AccountConfig.get_current().support_github else func(self, request)
Beispiel #3
0
 def inner(self, request):
     return Response({'err_msg':'work wechat qr not allowed'}, HTTP_403_FORBIDDEN)\
         if not AccountConfig.get_current().support_work_wechat_qr else func(self, request)