feat: 授权关联用户账号 — 登录记录设备, 激活时卡密存账号, 换设备登录自动授权(最多10台), 用户中心显示授权状态
This commit is contained in:
1 parent
3cd73d7f62
commit
70e03feca6
4 files changed
+133
-4
No files matched your search
@@ -162,9 +162,22 @@ export async function activateCard(cardKey: string, contactQq: string, replace =
|
||||
licenseState.activateSuccess = false;
|
||||
try {
|
||||
// 走本站 relay:API Key 只存在服务端,且 relay 先用 /verify 预检卡密
|
||||
// attach the logged-in account token so the card is bound to the account (follows across devices)
|
||||
let authHeader = '';
|
||||
try {
|
||||
const auth = JSON.parse(localStorage.getItem('it-tools-auth') ?? 'null');
|
||||
if (auth?.token) {
|
||||
authHeader = `Bearer ${auth.token}`;
|
||||
}
|
||||
}
|
||||
catch { /* ignore */ }
|
||||
const actHeaders: Record<string, string> = { 'Content-Type': 'application/json' };
|
||||
if (authHeader) {
|
||||
actHeaders['Authorization'] = authHeader;
|
||||
}
|
||||
const res = await fetch('/relay/activate', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
headers: actHeaders,
|
||||
body: JSON.stringify({
|
||||
card_key: key,
|
||||
machine_id: getMachineId(),
|
||||
|
||||
Reference in new issue
Block a user