feat: license page uses per-customer client token wording.
Align redeem/validate UX with per-code tokens from the auth server. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -72,16 +72,16 @@ def client_key() -> str:
|
||||
|
||||
|
||||
def set_client_api_key(key: str) -> dict[str, Any]:
|
||||
"""保存用户在授权页填写的 CLIENT_API_KEY(写入 license_state.json)。"""
|
||||
"""保存用户在授权页填写的客户密钥 / client token(写入 license_state.json)。"""
|
||||
key = (key or "").strip()
|
||||
if len(key) < 8:
|
||||
return {"ok": False, "message": "CLIENT_API_KEY 太短"}
|
||||
return {"ok": False, "message": "客户密钥太短"}
|
||||
with _lock:
|
||||
st = _read_state()
|
||||
st["client_api_key"] = key
|
||||
_write_state(st)
|
||||
os.environ["LICENSE_CLIENT_KEY"] = key
|
||||
return {"ok": True, "message": "CLIENT_API_KEY 已保存"}
|
||||
return {"ok": True, "message": "客户密钥已保存"}
|
||||
|
||||
|
||||
def offline_grace_hours() -> float:
|
||||
@@ -180,7 +180,7 @@ def _parse_expires_at(value: str | None) -> float | None:
|
||||
def _http_json(method: str, path: str, body: dict[str, Any]) -> dict[str, Any]:
|
||||
key = client_key()
|
||||
if not key:
|
||||
return {"ok": False, "message": "未配置 CLIENT_API_KEY。请在软件授权页填写卖家提供的密钥,或在 license.env 中设置 LICENSE_CLIENT_KEY。"}
|
||||
return {"ok": False, "message": "未配置客户密钥。请在软件授权页填写卖家提供的客户密钥(与激活码一起发放)。"}
|
||||
url = f"{api_base_url()}{path}"
|
||||
payload = json.dumps(body).encode("utf-8")
|
||||
req = Request(
|
||||
@@ -221,7 +221,7 @@ def redeem_code(code: str, client_api_key: str | None = None) -> dict[str, Any]:
|
||||
if not client_key():
|
||||
return {
|
||||
"ok": False,
|
||||
"message": "请先填写 CLIENT_API_KEY(向卖家索取,与授权站后台「系统设置」中的密钥一致)",
|
||||
"message": "请先填写客户密钥(与激活码一起由卖家提供;续费时可留空沿用本地已保存的密钥)",
|
||||
}
|
||||
device_id = get_device_id()
|
||||
result = _http_json("POST", "/v1/redeem", {"device_id": device_id, "code": code})
|
||||
|
||||
@@ -73,7 +73,7 @@
|
||||
<body>
|
||||
<div class="box">
|
||||
<h1>软件授权</h1>
|
||||
<p class="muted">复制设备 ID,联系微信 <strong>{{ wechat }}</strong> 获取 <strong>CLIENT_API_KEY</strong> 与激活码。授权站:{{ api_url }}</p>
|
||||
<p class="muted">复制设备 ID,联系微信 <strong>{{ wechat }}</strong> 获取 <strong>客户密钥</strong> 与激活码。授权站:{{ api_url }}</p>
|
||||
|
||||
{% if message %}<p class="ok">{{ message }}</p>{% endif %}
|
||||
{% if error %}<p class="err">{{ error }}</p>{% endif %}
|
||||
@@ -85,9 +85,9 @@
|
||||
|
||||
<form method="post" action="/license">
|
||||
<div class="row">
|
||||
<label>CLIENT_API_KEY</label>
|
||||
<input type="text" name="client_api_key" placeholder="{% if status.has_client_key %}已保存 {{ status.client_key_masked }},可留空或填写新密钥{% else %}粘贴卖家提供的 CLIENT_API_KEY{% endif %}" autocomplete="off" {% if not status.has_client_key %}required{% endif %}>
|
||||
<div class="hint">与授权站后台「系统设置」中的密钥一致,本地保存后下次可留空。</div>
|
||||
<label>客户密钥</label>
|
||||
<input type="text" name="client_api_key" placeholder="{% if status.has_client_key %}已保存 {{ status.client_key_masked }},可留空或填写新密钥{% else %}粘贴卖家提供的客户密钥(与激活码一起发放){% endif %}" autocomplete="off" {% if not status.has_client_key %}required{% endif %}>
|
||||
<div class="hint">每张激活码绑定独立密钥;兑换后本地保存,续费一般可留空。</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<label>激活码</label>
|
||||
|
||||
Reference in New Issue
Block a user