Spaces:
Running
Running
Upload 5 files
Browse files- router_items.py +3 -1
- router_proxy.py +4 -1
- verify_code_engine.py +14 -4
- 云端_定时版本检测引擎.py +3 -1
router_items.py
CHANGED
|
@@ -198,7 +198,9 @@ async def get_creator_details(account: str):
|
|
| 198 |
|
| 199 |
@router.post("/api/items")
|
| 200 |
async def create_item(item: ItemCreate):
|
| 201 |
-
|
|
|
|
|
|
|
| 202 |
if item.price < 0:
|
| 203 |
raise HTTPException(status_code=400, detail="🚨 安全拦截:商品价格不能为负数")
|
| 204 |
|
|
|
|
| 198 |
|
| 199 |
@router.post("/api/items")
|
| 200 |
async def create_item(item: ItemCreate):
|
| 201 |
+
if not item.type:
|
| 202 |
+
raise HTTPException(status_code=400, detail="资源类型不能为空")
|
| 203 |
+
item.price = int(item.price or 0)
|
| 204 |
if item.price < 0:
|
| 205 |
raise HTTPException(status_code=400, detail="🚨 安全拦截:商品价格不能为负数")
|
| 206 |
|
router_proxy.py
CHANGED
|
@@ -48,7 +48,10 @@ async def proxy_github_zip(req_data: ProxyGithubZipRequest, db: Session = Depend
|
|
| 48 |
if not item: return JSONResponse(content={"error": "资源不存在"}, status_code=404)
|
| 49 |
|
| 50 |
# 1. 核心鉴权:验证用户是否购买过该工具
|
| 51 |
-
|
|
|
|
|
|
|
|
|
|
| 52 |
if price > 0 and req_data.account != item.get("author"):
|
| 53 |
owned = db.query(Ownership).filter(Ownership.account == req_data.account, Ownership.item_id == req_data.item_id).first()
|
| 54 |
if not owned:
|
|
|
|
| 48 |
if not item: return JSONResponse(content={"error": "资源不存在"}, status_code=404)
|
| 49 |
|
| 50 |
# 1. 核心鉴权:验证用户是否购买过该工具
|
| 51 |
+
try:
|
| 52 |
+
price = int(float(item.get("price", 0) or 0))
|
| 53 |
+
except (ValueError, TypeError):
|
| 54 |
+
price = 0
|
| 55 |
if price > 0 and req_data.account != item.get("author"):
|
| 56 |
owned = db.query(Ownership).filter(Ownership.account == req_data.account, Ownership.item_id == req_data.item_id).first()
|
| 57 |
if not owned:
|
verify_code_engine.py
CHANGED
|
@@ -97,7 +97,7 @@ def send_email_code(to_email: str, code: str, action: str):
|
|
| 97 |
参数:
|
| 98 |
- to_email: 目标邮箱地址
|
| 99 |
- code: 6位数字验证码
|
| 100 |
-
- action: 动作类型 ("register" 注册 / "reset" 重置密码)
|
| 101 |
关联:
|
| 102 |
- 环境变量 MAKE_WEBHOOK_URL (在 HF Space Settings 中配置)
|
| 103 |
- router_users_auth.py 的 send_verify_code() 异步调用此函数
|
|
@@ -110,7 +110,12 @@ def send_email_code(to_email: str, code: str, action: str):
|
|
| 110 |
return
|
| 111 |
|
| 112 |
# 根据动作类型生成不同的邮件标题
|
| 113 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
subject = f"ComfyUI 社区 - {action_str}验证码"
|
| 115 |
|
| 116 |
# 构建 HTML 格式的邮件正文(美化样式)
|
|
@@ -154,13 +159,18 @@ def send_sms_code(phone: str, code: str, action: str):
|
|
| 154 |
参数:
|
| 155 |
- phone: 手机号(需带国际区号,如 +86)
|
| 156 |
- code: 6位数字验证码
|
| 157 |
-
- action: 动作类型 ("register" 注册 / "reset" 重置密码)
|
| 158 |
关联:
|
| 159 |
- 环境变量 TWILIO_SID, TWILIO_TOKEN, TWILIO_FROM (Twilio配置)
|
| 160 |
- 环境变量 ALIYUN_AK, ALIYUN_SK, ALIYUN_SIGN_NAME (阿里云配置)
|
| 161 |
- router_users_auth.py 的 send_verify_code() 异步调用此函数
|
| 162 |
"""
|
| 163 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 164 |
|
| 165 |
# ==========================================
|
| 166 |
# 引擎 A:Twilio (海外优先,无需SDK,纯HTTP接口)
|
|
|
|
| 97 |
参数:
|
| 98 |
- to_email: 目标邮箱地址
|
| 99 |
- code: 6位数字验证码
|
| 100 |
+
- action: 动作类型 ("register" 注册 / "reset" 重置密码 / "withdraw" 提现)
|
| 101 |
关联:
|
| 102 |
- 环境变量 MAKE_WEBHOOK_URL (在 HF Space Settings 中配置)
|
| 103 |
- router_users_auth.py 的 send_verify_code() 异步调用此函数
|
|
|
|
| 110 |
return
|
| 111 |
|
| 112 |
# 根据动作类型生成不同的邮件标题
|
| 113 |
+
if action == "register":
|
| 114 |
+
action_str = "注册账号"
|
| 115 |
+
elif action == "withdraw":
|
| 116 |
+
action_str = "提现操作"
|
| 117 |
+
else:
|
| 118 |
+
action_str = "修改/找回密码"
|
| 119 |
subject = f"ComfyUI 社区 - {action_str}验证码"
|
| 120 |
|
| 121 |
# 构建 HTML 格式的邮件正文(美化样式)
|
|
|
|
| 159 |
参数:
|
| 160 |
- phone: 手机号(需带国际区号,如 +86)
|
| 161 |
- code: 6位数字验证码
|
| 162 |
+
- action: 动作类型 ("register" 注册 / "reset" 重置密码 / "withdraw" 提现)
|
| 163 |
关联:
|
| 164 |
- 环境变量 TWILIO_SID, TWILIO_TOKEN, TWILIO_FROM (Twilio配置)
|
| 165 |
- 环境变量 ALIYUN_AK, ALIYUN_SK, ALIYUN_SIGN_NAME (阿里云配置)
|
| 166 |
- router_users_auth.py 的 send_verify_code() 异步调用此函数
|
| 167 |
"""
|
| 168 |
+
if action == "register":
|
| 169 |
+
action_str = "注册账号"
|
| 170 |
+
elif action == "withdraw":
|
| 171 |
+
action_str = "提现操作"
|
| 172 |
+
else:
|
| 173 |
+
action_str = "修改/找回密码"
|
| 174 |
|
| 175 |
# ==========================================
|
| 176 |
# 引擎 A:Twilio (海外优先,无需SDK,纯HTTP接口)
|
云端_定时版本检测引擎.py
CHANGED
|
@@ -34,7 +34,9 @@ async def fetch_latest_github_hash(repo_url, token):
|
|
| 34 |
if resp.status_code == 200:
|
| 35 |
data = resp.json()
|
| 36 |
if isinstance(data, list) and len(data) > 0:
|
| 37 |
-
|
|
|
|
|
|
|
| 38 |
elif resp.status_code == 403: # Rate limit
|
| 39 |
logger.warning(f"GitHub API 速率限制: {repo_url}")
|
| 40 |
return None
|
|
|
|
| 34 |
if resp.status_code == 200:
|
| 35 |
data = resp.json()
|
| 36 |
if isinstance(data, list) and len(data) > 0:
|
| 37 |
+
latest_commit = data[0]
|
| 38 |
+
if isinstance(latest_commit, dict) and "sha" in latest_commit:
|
| 39 |
+
return latest_commit["sha"][:7] # 返回最新的 Commit Hash
|
| 40 |
elif resp.status_code == 403: # Rate limit
|
| 41 |
logger.warning(f"GitHub API 速率限制: {repo_url}")
|
| 42 |
return None
|