MCPcopy Create free account
hub / github.com/QLHazyCoder/FlowPilot / storeAuthSession

Function storeAuthSession

content/sub2api-panel.js:120–138  ·  view source on GitHub ↗
(loginData)

Source from the content-addressed store, hash-verified

118}
119
120function storeAuthSession(loginData) {
121 if (!loginData?.access_token) {
122 throw new Error('SUB2API 登录返回缺少 access_token。');
123 }
124
125 localStorage.setItem('auth_token', loginData.access_token);
126 if (loginData.refresh_token) {
127 localStorage.setItem('refresh_token', loginData.refresh_token);
128 } else {
129 localStorage.removeItem('refresh_token');
130 }
131 if (loginData.expires_in) {
132 localStorage.setItem('token_expires_at', String(Date.now() + Number(loginData.expires_in) * 1000));
133 }
134 if (loginData.user) {
135 localStorage.setItem('auth_user', JSON.stringify(loginData.user));
136 }
137 sessionStorage.removeItem('auth_expired');
138}
139
140async function loginSub2Api(payload = {}) {
141 const email = (payload.sub2apiEmail || '').trim();

Callers 1

loginSub2ApiFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected