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

Function loginSub2Api

content/sub2api-panel.js:140–167  ·  view source on GitHub ↗
(payload = {})

Source from the content-addressed store, hash-verified

138}
139
140async function loginSub2Api(payload = {}) {
141 const email = (payload.sub2apiEmail || '').trim();
142 const password = payload.sub2apiPassword || '';
143 const origin = getSub2ApiOrigin(payload);
144
145 if (!email) {
146 throw new Error('缺少 SUB2API 登录邮箱,请先在侧边栏填写。');
147 }
148 if (!password) {
149 throw new Error('缺少 SUB2API 登录密码,请先在侧边栏填写。');
150 }
151
152 log('步骤:正在登录 SUB2API 后台...');
153 const loginData = await requestJson(origin, '/api/v1/auth/login', {
154 method: 'POST',
155 body: {
156 email,
157 password,
158 },
159 });
160 storeAuthSession(loginData);
161
162 return {
163 origin,
164 token: loginData.access_token,
165 user: loginData.user || null,
166 };
167}
168
169async function getGroupByName(origin, token, groupName) {
170 const targetName = (groupName || SUB2API_DEFAULT_GROUP_NAME).trim() || SUB2API_DEFAULT_GROUP_NAME;

Callers 2

Calls 4

getSub2ApiOriginFunction · 0.85
logFunction · 0.85
requestJsonFunction · 0.85
storeAuthSessionFunction · 0.85

Tested by

no test coverage detected