From 4efc442977a2ef7306ea5fa1ee252250b9b5e854 Mon Sep 17 00:00:00 2001 From: personal82555 Date: Tue, 13 Oct 2026 12:16:05 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=8D=A2=E7=94=B5=E8=84=91=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E5=B7=B2=E6=8E=88=E6=9D=83=E8=B4=A6=E5=8F=B7=E4=BB=8D?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E6=9C=AA=E6=8E=88=E6=9D=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 后端 _account_license_ok: 账号持有有效卡或绑定过任一已授权机器即视为账号已授权, 所有登录设备继承授权(覆盖卡激活在设备未关联账号场景) - 前端 LicenseGate: 登录/登出后重查授权(it-tools-auth-changed), 不再停留首次缓存的未授权态 - CHANGELOG记录 验证: 新机器登录 auth-status=true 受控工具放行; 无关机器仍未授权 --- CHANGELOG.md | 6 ++++++ docker/it-tools-relay/server.py | 21 +++++++++++++++++---- src/tools/license/LicenseGate.vue | 6 ++++++ 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 79e7b4f..52b0eaa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. See [standa ## Version 2026.10.12-it-tools-pro +### 🔑 修复:换电脑登录已授权账号仍提示未授权 +- 后端 `_account_license_ok` 改进:账号持有有效卡、或账号绑定过任一已授权机器,即视为账号已授权——登录该账号的所有设备自动继承授权(卡激活在设备、未关联账号的场景也覆盖) +- 前端授权闸门(LicenseGate)登录/登出后自动重新检查授权,不再停留在首次加载时缓存的「未授权」状态 +- 验证:新机器登录后 auth-status 返回 authorized=true,受控工具直接放行;无关机器仍为未授权 + + 基于 IT-Tools 深度定制的一次大版本更新:新增 7 个 AI 工具、专业编辑器、用户中心与管理后台,授权与体验全面升级。 ### 🤖 新增 AI 工具(受控授权,各 30 分钟免费试用) diff --git a/docker/it-tools-relay/server.py b/docker/it-tools-relay/server.py index d9f6888..0099dca 100644 --- a/docker/it-tools-relay/server.py +++ b/docker/it-tools-relay/server.py @@ -525,7 +525,14 @@ def check(machine: str, tool: str) -> int: def _account_license_ok(machine: str) -> bool: - """True when this device logged into an account holding an active card.""" + """True when this device logged into an authorized account. + + An account is authorized when either: + * it holds an active card (card_key + origin_machine active on CardAuth), or + * it is bound to at least one machine that itself is authorized on CardAuth + (covers cards activated on a device without account context). + Either way, every device that logs into this account inherits the license. + """ try: conn = _db() rows = conn.execute("SELECT card_key, origin_machine, bound_machines FROM users").fetchall() @@ -533,14 +540,20 @@ def _account_license_ok(machine: str) -> bool: except Exception: return False for card_key, origin, bm_json in rows: - if not card_key or not origin: + if not card_key and not bm_json: continue try: machines = json.loads(bm_json or "[]") except Exception: machines = [] - if machine in machines: - if origin == machine or query_authorized(origin): + if machine not in machines: + continue + # account carries an active card + if card_key and origin and (origin == machine or query_authorized(origin)): + return True + # account shares a device that is itself authorized (max 4 lookups, cached) + for bm in machines[:4]: + if bm and bm != machine and bm not in _load_revoked() and query_authorized(bm): return True return False diff --git a/src/tools/license/LicenseGate.vue b/src/tools/license/LicenseGate.vue index 22db1b8..c645459 100644 --- a/src/tools/license/LicenseGate.vue +++ b/src/tools/license/LicenseGate.vue @@ -109,6 +109,12 @@ onMounted(() => { timer = setInterval(() => { now.value = Date.now(); }, 1000); + // 登录/登出后重新检查授权:换电脑登录已授权账号后,立即解除未授权提示 + window.addEventListener('it-tools-auth-changed', init); +}); + +onBeforeUnmount(() => { + window.removeEventListener('it-tools-auth-changed', init); }); // 跨工具路由复用:路径变化时重新走授权检查