fix: 换电脑登录已授权账号仍提示未授权

- 后端 _account_license_ok: 账号持有有效卡或绑定过任一已授权机器即视为账号已授权, 所有登录设备继承授权(覆盖卡激活在设备未关联账号场景)
- 前端 LicenseGate: 登录/登出后重查授权(it-tools-auth-changed), 不再停留首次缓存的未授权态
- CHANGELOG记录

验证: 新机器登录 auth-status=true 受控工具放行; 无关机器仍未授权
This commit is contained in:
personal82555 committed 2026-10-13 12:16:05 +08:00
1 parent 8124e88a53
commit 4efc442977
3 files changed
+29 -4

No files matched your search

+6
View File
@@ -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 分钟免费试用)
+17 -4
View File
@@ -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
+6
View File
@@ -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);
});
// 跨工具路由复用:路径变化时重新走授权检查