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})
|
||||
|
||||
Reference in New Issue
Block a user