添加报表页面,更新用户管理和注册功能
This commit is contained in:
@@ -70,38 +70,36 @@ def register():
|
||||
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 or email_verify_enabled:
|
||||
hourly_limit = int(auto_approve_hourly_limit) if isinstance(auto_approve_hourly_limit, int) else 10
|
||||
if hourly_limit > 0:
|
||||
hourly_count = database.get_hourly_registration_count()
|
||||
if hourly_count >= auto_approve_hourly_limit:
|
||||
return jsonify({"error": f"注册人数过多,请稍后再试(每小时限制{auto_approve_hourly_limit}人)"}), 429
|
||||
if hourly_count >= hourly_limit:
|
||||
return jsonify({"error": f"注册人数过多,请稍后再试(每小时限制{hourly_limit}人)"}), 429
|
||||
|
||||
user_id = database.create_user(username, password, email)
|
||||
if user_id:
|
||||
if auto_approve_enabled:
|
||||
if auto_approve_vip_days > 0:
|
||||
database.set_user_vip(user_id, auto_approve_vip_days)
|
||||
|
||||
if email_verify_enabled and email:
|
||||
result = email_service.send_register_verification_email(email=email, username=username, user_id=user_id)
|
||||
if result["success"]:
|
||||
return jsonify(
|
||||
{
|
||||
"success": True,
|
||||
"message": "注册成功!验证邮件已发送,请查收邮箱并点击链接完成验证",
|
||||
"need_verify": True,
|
||||
}
|
||||
)
|
||||
message = "注册成功!验证邮件已发送(可直接登录,建议完成邮箱验证)"
|
||||
if auto_approve_enabled and auto_approve_vip_days > 0:
|
||||
message += f",赠送{auto_approve_vip_days}天VIP"
|
||||
return jsonify({"success": True, "message": message, "need_verify": True})
|
||||
|
||||
logger.error(f"注册验证邮件发送失败: {result['error']}")
|
||||
return jsonify(
|
||||
{
|
||||
"success": True,
|
||||
"message": f"注册成功,但验证邮件发送失败({result['error']})。请稍后在登录页面重新发送验证邮件",
|
||||
"need_verify": True,
|
||||
}
|
||||
)
|
||||
if auto_approve_enabled:
|
||||
database.approve_user(user_id)
|
||||
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"})
|
||||
return jsonify({"success": True, "message": "注册成功!已自动审核通过"})
|
||||
return jsonify({"success": True, "message": "注册成功,请等待管理员审核"})
|
||||
message = f"注册成功,但验证邮件发送失败({result['error']})。你仍可直接登录"
|
||||
if auto_approve_enabled and auto_approve_vip_days > 0:
|
||||
message += f",赠送{auto_approve_vip_days}天VIP"
|
||||
return jsonify({"success": True, "message": message, "need_verify": True})
|
||||
|
||||
message = "注册成功!可直接登录"
|
||||
if auto_approve_enabled and auto_approve_vip_days > 0:
|
||||
message += f",赠送{auto_approve_vip_days}天VIP"
|
||||
return jsonify({"success": True, "message": message})
|
||||
return jsonify({"error": "用户名已存在"}), 400
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user