refactor: 移除 2FA 功能与三个冗余依赖
2FA 早已是死代码:TOTP 相关端点标注为前端未调用,前端唯一的 two_factor_auth 是硬编码 false,没有任何入口能打开它。 - 删除 TwoFactorAuthAPI、CheckTFARequiredAPI、_totp* 辅助函数、 TwoFactorAuthCodeSerializer 及各 serializer 的 tfa_code 字段 - 删除管理端写 two_factor_auth/tfa_token 的分支。登录已不再校验 TOTP,若保留写入路径,置 True 会变成静默的安全降级 - 删除 User.two_factor_auth / tfa_token 字段(迁移 0009) - 移除 django-dbconn-retry:仅挂在 INSTALLED_APPS,代码零引用。 DATABASES 未配置 CONN_MAX_AGE(默认 0),本就没有持久连接需要 重连修复。要开持久连接用 Django 自带的 CONN_HEALTH_CHECKS - requests 换成 httpx(openai 已经引入):删除废弃的 ReleaseNotesAPI,judge dispatcher 显式传 timeout=None 以保持 requests 原本的无超时行为,判题请求是同步等结果的 依赖净减 5 个:otpauth、qrcode、requests、charset-normalizer、 django-dbconn-retry Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,19 +1,15 @@
|
||||
import asyncio
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import random
|
||||
import re
|
||||
import shutil
|
||||
import smtplib
|
||||
import time
|
||||
from datetime import timedelta
|
||||
|
||||
import requests
|
||||
from asgiref.sync import sync_to_async
|
||||
from django.conf import settings
|
||||
from django.utils import timezone
|
||||
from requests.exceptions import RequestException
|
||||
|
||||
from account.decorators import super_admin_required
|
||||
from account.models import User
|
||||
@@ -253,23 +249,6 @@ class TestCasePruneAPI(APIView):
|
||||
shutil.rmtree(test_case_dir, ignore_errors=True)
|
||||
|
||||
|
||||
# DEPRECATED: 前端未调用 (2026-05-26)
|
||||
class ReleaseNotesAPI(APIView):
|
||||
def get(self, request):
|
||||
try:
|
||||
resp = requests.get(
|
||||
"https://raw.githubusercontent.com/QingdaoU/OnlineJudge/master/docs/data.json?_=" + str(time.time()),
|
||||
timeout=3,
|
||||
)
|
||||
releases = resp.json()
|
||||
except (RequestException, ValueError):
|
||||
return self.success()
|
||||
with open("docs/data.json", "r") as f:
|
||||
local_version = json.load(f)["update"][0]["version"]
|
||||
releases["local_version"] = local_version
|
||||
return self.success(releases)
|
||||
|
||||
|
||||
class DashboardInfoAPI(AsyncAPIView):
|
||||
async def get(self, request):
|
||||
now = timezone.now()
|
||||
|
||||
Reference in New Issue
Block a user