MCPcopy Create free account
hub / github.com/smallfawn/QLScriptPublic / autoLogin

Method autoLogin

wxapp/vipshop.js:302–326  ·  view source on GitHub ↗
(code)

Source from the content-addressed store, hash-verified

300 }
301
302 async autoLogin(code) {
303 const data = {
304 ...this.baseData(),
305 hash: HASH,
306 code,
307 event: 2,
308 deviceId: this.marsCid,
309 context: JSON.stringify({ iv: "", encryptedData: "" }),
310 source_app_type: "shop_weixin_mina",
311 login_type: "WEIXIN_SMALL_APP",
312 third_type: "WEIXIN",
313 };
314 const { status, data: res } = await request({
315 method: "POST",
316 url: `https://mapi.vip.com/vips-mobile/rest/auth/third_party/trylogin/v1?api_key=${API_KEY}`,
317 headers: { "Content-Type": "application/x-www-form-urlencoded", Cookie: this.cookie() },
318 data: form(data),
319 });
320 if (status !== 200 || Number(res?.code) !== 1 || !res?.data?.tokenId) {
321 throw new Error(`自动登录失败 HTTP ${status}: ${short(res)}`);
322 }
323 this.token = res.data.tokenId;
324 this.userId = String(res.data.userId || "");
325 this.log(`登录成功 userId=${this.userId || "-"} VIP_TANK=${mask(this.token)}`);
326 }
327
328 async ensureLogin() {
329 this.loadCache();

Callers 1

ensureLoginMethod · 0.95

Calls 7

baseDataMethod · 0.95
cookieMethod · 0.95
logMethod · 0.95
formFunction · 0.85
requestFunction · 0.70
shortFunction · 0.70
maskFunction · 0.70

Tested by

no test coverage detected