添加注册自动审核功能

- 系统配置新增:自动审核开关、每小时注册限制、赠送VIP天数
- 数据库:添加 auto_approve_enabled, auto_approve_hourly_limit, auto_approve_vip_days 字段
- 后端API:支持保存和读取自动审核配置
- 管理后台:新增注册自动审核配置区域(绿色背景)
- 注册逻辑:支持自动审核通过并赠送VIP

功能说明:
1. 启用自动审核后,新用户注册自动通过,无需管理员审批
2. 每小时注册限制防止恶意注册
3. 可配置注册赠送VIP天数(设为0则不赠送)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2025-12-10 21:42:28 +08:00
parent 841ac94c4b
commit d811fc7c56
3 changed files with 161 additions and 6 deletions

41
app.py
View File

@@ -460,9 +460,32 @@ def register():
return jsonify({"error": "验证码错误次数过多,IP已被锁定1小时"}), 429
return jsonify({"error": message}), 400
# 获取自动审核配置
system_config = database.get_system_config()
auto_approve_enabled = system_config.get('auto_approve_enabled', 0) == 1
auto_approve_hourly_limit = system_config.get('auto_approve_hourly_limit', 10)
auto_approve_vip_days = system_config.get('auto_approve_vip_days', 7)
# 检查每小时注册限制
if auto_approve_enabled:
hourly_count = database.get_hourly_registration_count()
if hourly_count >= auto_approve_hourly_limit:
return jsonify({"error": f"注册人数过多,请稍后再试(每小时限制{auto_approve_hourly_limit}人)"}), 429
user_id = database.create_user(username, password, email)
if user_id:
return jsonify({"success": True, "message": "注册成功,请等待管理员审核"})
# 自动审核处理
if auto_approve_enabled:
# 自动审核通过
database.approve_user(user_id)
# 赠送VIP天数
if auto_approve_vip_days > 0:
database.set_user_vip(user_id, auto_approve_vip_days)
return jsonify({"success": True, "message": f"注册成功!已自动审核通过,赠送{auto_approve_vip_days}天VIP"})
else:
return jsonify({"success": True, "message": "注册成功!已自动审核通过"})
else:
return jsonify({"success": True, "message": "注册成功,请等待管理员审核"})
else:
return jsonify({"error": "用户名已存在"}), 400
@@ -2320,6 +2343,9 @@ def update_system_config_api():
schedule_weekdays = data.get('schedule_weekdays')
new_max_concurrent_per_account = data.get('max_concurrent_per_account')
new_max_screenshot_concurrent = data.get('max_screenshot_concurrent')
auto_approve_enabled = data.get('auto_approve_enabled')
auto_approve_hourly_limit = data.get('auto_approve_hourly_limit')
auto_approve_vip_days = data.get('auto_approve_vip_days')
# 验证参数
if max_concurrent is not None:
@@ -2353,6 +2379,14 @@ def update_system_config_api():
except (ValueError, AttributeError):
return jsonify({"error": "星期格式错误"}), 400
if auto_approve_hourly_limit is not None:
if not isinstance(auto_approve_hourly_limit, int) or auto_approve_hourly_limit < 1:
return jsonify({"error": "每小时注册限制必须大于0"}), 400
if auto_approve_vip_days is not None:
if not isinstance(auto_approve_vip_days, int) or auto_approve_vip_days < 0:
return jsonify({"error": "注册赠送VIP天数不能为负数"}), 400
# 更新数据库
if database.update_system_config(
max_concurrent=max_concurrent,
@@ -2361,7 +2395,10 @@ def update_system_config_api():
schedule_browse_type=schedule_browse_type,
schedule_weekdays=schedule_weekdays,
max_concurrent_per_account=new_max_concurrent_per_account,
max_screenshot_concurrent=new_max_screenshot_concurrent
max_screenshot_concurrent=new_max_screenshot_concurrent,
auto_approve_enabled=auto_approve_enabled,
auto_approve_hourly_limit=auto_approve_hourly_limit,
auto_approve_vip_days=auto_approve_vip_days
):
# 如果修改了并发数,更新全局变量和信号量
if max_concurrent is not None and max_concurrent != max_concurrent_global: