feat: accept CLIENT_API_KEY on /license page.

Users can paste the key from the seller instead of editing license.env; it persists in license_state.json.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-17 17:20:47 +08:00
parent 863da10d1f
commit 8eefc6cfd5
6 changed files with 91 additions and 32 deletions
+7 -3
View File
@@ -51,8 +51,11 @@ def install_license_middleware(app: FastAPI) -> None:
data = await request.json()
except Exception:
data = {}
code = (data.get("code") if isinstance(data, dict) else "") or ""
return redeem_code(str(code))
if not isinstance(data, dict):
data = {}
code = str(data.get("code") or "").strip()
ckey = str(data.get("client_api_key") or "").strip()
return redeem_code(code, client_api_key=ckey or None)
@app.post("/api/license/validate")
async def _license_validate_api():
@@ -65,7 +68,8 @@ def install_license_middleware(app: FastAPI) -> None:
if request.method == "POST":
form = await request.form()
code = str(form.get("code") or "").strip()
result = redeem_code(code)
ckey = str(form.get("client_api_key") or "").strip()
result = redeem_code(code, client_api_key=ckey or None)
if result.get("ok"):
msg = result.get("message") or "激活成功"
else: