diff --git a/auth/.DS_Store b/auth/.DS_Store deleted file mode 100644 index a292f56..0000000 Binary files a/auth/.DS_Store and /dev/null differ diff --git a/auth/MyRateThrottle.py b/auth/MyRateThrottle.py deleted file mode 100644 index 114ade5..0000000 --- a/auth/MyRateThrottle.py +++ /dev/null @@ -1,5 +0,0 @@ -from rest_framework.throttling import AnonRateThrottle - - -class MyRateThrottle(AnonRateThrottle): - THROTTLE_RATES = {"anon": "5/min"} diff --git a/auth/__init__.py b/auth/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/auth/__pycache__/MyRateThrottle.cpython-312.pyc b/auth/__pycache__/MyRateThrottle.cpython-312.pyc deleted file mode 100644 index 2409c78..0000000 Binary files a/auth/__pycache__/MyRateThrottle.cpython-312.pyc and /dev/null differ diff --git a/auth/__pycache__/MyRateThrottle.cpython-38.pyc b/auth/__pycache__/MyRateThrottle.cpython-38.pyc deleted file mode 100644 index 0ae2d6b..0000000 Binary files a/auth/__pycache__/MyRateThrottle.cpython-38.pyc and /dev/null differ diff --git a/auth/__pycache__/__init__.cpython-312.pyc b/auth/__pycache__/__init__.cpython-312.pyc deleted file mode 100644 index 9de525d..0000000 Binary files a/auth/__pycache__/__init__.cpython-312.pyc and /dev/null differ diff --git a/auth/__pycache__/__init__.cpython-38.pyc b/auth/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index 41311d2..0000000 Binary files a/auth/__pycache__/__init__.cpython-38.pyc and /dev/null differ diff --git a/auth/__pycache__/authentication.cpython-312.pyc b/auth/__pycache__/authentication.cpython-312.pyc deleted file mode 100644 index 7fcd63d..0000000 Binary files a/auth/__pycache__/authentication.cpython-312.pyc and /dev/null differ diff --git a/auth/__pycache__/authentication.cpython-38.pyc b/auth/__pycache__/authentication.cpython-38.pyc deleted file mode 100644 index 935b18d..0000000 Binary files a/auth/__pycache__/authentication.cpython-38.pyc and /dev/null differ diff --git a/auth/authentication.py b/auth/authentication.py deleted file mode 100644 index 38f7c91..0000000 --- a/auth/authentication.py +++ /dev/null @@ -1,45 +0,0 @@ -from rest_framework import exceptions -from rest_framework.authentication import BaseAuthentication - -from myapp.models import User - - -# 后台接口认证 -class AdminTokenAuthtication(BaseAuthentication): - def authenticate(self, request): - adminToken = request.META.get("HTTP_ADMINTOKEN") - print("检查adminToken==>" + adminToken) - users = User.objects.filter(admin_token=adminToken) - """ - 判定条件: - 1. 传了adminToken - 2. 查到了该帐号 - 3. 该帐号是管理员或演示帐号 - """ - if not adminToken or len(users) == 0 or users[0].role == '2': - raise exceptions.AuthenticationFailed("AUTH_FAIL_END") - else: - print('adminToken验证通过') - - -# 前台接口认证 -class TokenAuthtication(BaseAuthentication): - def authenticate(self, request): - token = request.META.get("HTTP_TOKEN", "") - if token is not None: - print("检查token==>" + token) - users = User.objects.filter(token=token) - # print(users) - """ - 判定条件: - 1. 传了token - 2. 查到了该帐号 - 3. 该帐号是普通用户 - """ - if not token or len(users) == 0 or (users[0].role in ['1', '3']): - raise exceptions.AuthenticationFailed("AUTH_FAIL_FRONT") - else: - print('token验证通过') - else: - print("检查token==>token 为空") - raise exceptions.AuthenticationFailed("AUTH_FAIL_FRONT") diff --git a/permission/.DS_Store b/permission/.DS_Store deleted file mode 100644 index 5008ddf..0000000 Binary files a/permission/.DS_Store and /dev/null differ diff --git a/permission/__init__.py b/permission/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/permission/__pycache__/__init__.cpython-312.pyc b/permission/__pycache__/__init__.cpython-312.pyc deleted file mode 100644 index 9dd905b..0000000 Binary files a/permission/__pycache__/__init__.cpython-312.pyc and /dev/null differ diff --git a/permission/__pycache__/__init__.cpython-38.pyc b/permission/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index 2e837b9..0000000 Binary files a/permission/__pycache__/__init__.cpython-38.pyc and /dev/null differ diff --git a/permission/__pycache__/permission.cpython-312.pyc b/permission/__pycache__/permission.cpython-312.pyc deleted file mode 100644 index bec244e..0000000 Binary files a/permission/__pycache__/permission.cpython-312.pyc and /dev/null differ diff --git a/permission/__pycache__/permission.cpython-38.pyc b/permission/__pycache__/permission.cpython-38.pyc deleted file mode 100644 index 4813d16..0000000 Binary files a/permission/__pycache__/permission.cpython-38.pyc and /dev/null differ diff --git a/permission/permission.py b/permission/permission.py deleted file mode 100644 index e25a1e8..0000000 --- a/permission/permission.py +++ /dev/null @@ -1,12 +0,0 @@ -from myapp.models import User - - -def isDemoAdminUser(request): - adminToken = request.META.get("HTTP_ADMINTOKEN") - users = User.objects.filter(admin_token=adminToken) - if len(users) > 0: - user = users[0] - if user.role == '3': # (角色3)表示演示帐号 - print('演示帐号===>') - return True - return False