From a7f88efaba30f3a6b12e4f1252265b3d04e1e082 Mon Sep 17 00:00:00 2001 From: yangjian Date: Tue, 13 Apr 2021 21:19:42 +0800 Subject: [PATCH] =?UTF-8?q?restful=E6=8E=A5=E5=8F=A3=E5=90=8C=E6=97=B6?= =?UTF-8?q?=E6=94=AF=E6=8C=81token=E5=92=8Csession=E8=AE=A4=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app_api/permissions_app.py | 2 +- app_api/views_app.py | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app_api/permissions_app.py b/app_api/permissions_app.py index efe394a..2c0d333 100644 --- a/app_api/permissions_app.py +++ b/app_api/permissions_app.py @@ -5,7 +5,7 @@ # 博客地址:zmister.com from rest_framework.permissions import BasePermission,SAFE_METHODS - +from django.utils.translation import gettext_lazy as _ class AppPermission(BasePermission): message = _('只有VIP才能访问') diff --git a/app_api/views_app.py b/app_api/views_app.py index 15b9ba5..8dbabcc 100644 --- a/app_api/views_app.py +++ b/app_api/views_app.py @@ -15,6 +15,7 @@ from rest_framework.views import APIView from app_api.models import AppUserToken from rest_framework.response import Response from rest_framework.pagination import PageNumberPagination +from rest_framework.authentication import SessionAuthentication from app_doc.models import * from app_api.serializers_app import * from app_api.auth_app import AppAuth,AppMustAuth @@ -98,7 +99,7 @@ class LoginView(APIView): # 文集视图 class ProjectView(APIView): - authentication_classes = (AppAuth,) + authentication_classes = (AppAuth,SessionAuthentication) # 获取文集 def get(self,request): pro_id = request.query_params.get('id',None) @@ -428,7 +429,7 @@ class ProjectView(APIView): # 文档视图 class DocView(APIView): - authentication_classes = (AppAuth,) + authentication_classes = (AppAuth,SessionAuthentication) # 获取文档 def get(self,request): @@ -624,7 +625,7 @@ class DocView(APIView): # 文档模板视图 class DocTempView(APIView): - authentication_classes = (AppAuth,) + authentication_classes = (AppAuth,SessionAuthentication) # 获取文档模板 def get(self, request): @@ -708,7 +709,7 @@ class DocTempView(APIView): # 图片视图 class ImageView(APIView): - authentication_classes = (AppAuth,) + authentication_classes = (AppAuth,SessionAuthentication) def get(self, request): if request.auth: @@ -762,7 +763,7 @@ class ImageView(APIView): # 图片分组视图 class ImageGroupView(APIView): - authentication_classes = (AppMustAuth,) + authentication_classes = (AppAuth,SessionAuthentication) def get(self, request): try: @@ -817,7 +818,7 @@ class ImageGroupView(APIView): # 附件视图 class AttachmentView(APIView): - authentication_classes = (AppAuth,) + authentication_classes = (AppAuth,SessionAuthentication) # 文件大小 字节转换 def sizeFormat(size, is_disk=False, precision=2):