|
@@ -8,7 +8,7 @@ from rest_framework.views import APIView
|
|
|
from rest_framework.viewsets import ModelViewSet
|
|
|
|
|
|
from background.Object import AmazonS3Util, RedisObject, TokenObject
|
|
|
-# from background.author import MyAuthentication
|
|
|
+from background.author import MyAuthentication
|
|
|
from background.serializers import ProductInfoSerializer, VideoInSerializer, QuickStartInfoSerializer, \
|
|
|
UpgradeFirmwareInfoSerializer
|
|
|
from background.models import ProductInfo, VideoInfo, QuickStartInfo, UpgradeFirmwareInfo, WechatUserInfo
|
|
@@ -21,18 +21,18 @@ bucket = 'ansjerfilemanager'
|
|
|
class ProductInfoSet(ModelViewSet):
|
|
|
queryset = ProductInfo.objects.all()
|
|
|
serializer_class = ProductInfoSerializer
|
|
|
- # authentication_classes = [MyAuthentication, ]
|
|
|
+ authentication_classes = [MyAuthentication, ]
|
|
|
|
|
|
|
|
|
class VideoInfoSet(ModelViewSet):
|
|
|
- # authentication_classes = [MyAuthentication, ]
|
|
|
+ authentication_classes = [MyAuthentication, ]
|
|
|
queryset = VideoInfo.objects.all()
|
|
|
serializer_class = VideoInSerializer
|
|
|
filterset_fields = ['id', 'product_info_id', 'title']
|
|
|
|
|
|
|
|
|
class QuickStartInfoSet(ModelViewSet):
|
|
|
- # authentication_classes = [MyAuthentication, ]
|
|
|
+ authentication_classes = [MyAuthentication, ]
|
|
|
queryset = QuickStartInfo.objects.all()
|
|
|
serializer_class = QuickStartInfoSerializer
|
|
|
filterset_fields = ['id', 'product_info_id', 'title']
|
|
@@ -62,8 +62,8 @@ class UpgradeFirmwareInfoSet(ModelViewSet):
|
|
|
queryset = UpgradeFirmwareInfo.objects.all()
|
|
|
serializer_class = UpgradeFirmwareInfoSerializer
|
|
|
filterset_fields = ['id', 'product_info_id', 'title']
|
|
|
+ authentication_classes = [MyAuthentication, ]
|
|
|
|
|
|
- # authentication_classes = [MyAuthentication, ]
|
|
|
def create(self, request, *args, **kwargs):
|
|
|
link = request.data.get('link')
|
|
|
file_key = 'vsees/upgrade_firmware_file/{}'.format(link)
|
|
@@ -137,6 +137,7 @@ class WechatLoginView(APIView):
|
|
|
return Response({'code': 444, 'result': {'error_msg': '缺少参数'}})
|
|
|
# 验证state,获取token
|
|
|
access_token = cls.get_access_token(state)
|
|
|
+
|
|
|
if not access_token:
|
|
|
return Response({'code': 120, 'result': {'error_msg': '获取token失败'}})
|
|
|
data = {
|
|
@@ -186,7 +187,8 @@ class WechatLoginView(APIView):
|
|
|
data = token_response.json()
|
|
|
if data.get('errcode') == 0:
|
|
|
access_token = data['access_token']
|
|
|
- redis_client.set_data('enterprise_wechat_access_token', access_token)
|
|
|
+ expires_in = data['expires_in']
|
|
|
+ redis_client.set_data('enterprise_wechat_access_token', access_token, expires_in)
|
|
|
return access_token
|
|
|
else:
|
|
|
return False
|