fix: 更新会话cookie键名并添加随机会话生成
更新登录请求中的cookie键名从"_miucms_session"到"XPHP_SESSION_ID" 在应用启动时生成40位随机字符串作为会话ID
This commit is contained in:
parent
678d35042a
commit
93a3cb9b58
18
app.js
18
app.js
@ -3,7 +3,17 @@ var t = require("./utils/login.js");
|
|||||||
// 引入
|
// 引入
|
||||||
require("./utils/xstat.js");
|
require("./utils/xstat.js");
|
||||||
|
|
||||||
|
function generateRandomCode(length) {
|
||||||
|
let result = '';
|
||||||
|
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||||
|
const charactersLength = characters.length;
|
||||||
|
|
||||||
|
for (let i = 0; i < length; i++) {
|
||||||
|
result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
App({
|
App({
|
||||||
xstatConfig: {
|
xstatConfig: {
|
||||||
appKey: wx.getAccountInfoSync().miniProgram.appId, // 自动获取 小程序appid
|
appKey: wx.getAccountInfoSync().miniProgram.appId, // 自动获取 小程序appid
|
||||||
@ -12,6 +22,14 @@ App({
|
|||||||
LOG_URL: 'https://t-jm.v0750.com/v2/stat/send',
|
LOG_URL: 'https://t-jm.v0750.com/v2/stat/send',
|
||||||
},
|
},
|
||||||
onLaunch: function(e) {
|
onLaunch: function(e) {
|
||||||
|
|
||||||
|
// 40 位的随机码
|
||||||
|
if (!wx.getStorageSync("session")) {
|
||||||
|
wx.setStorageSync("session", generateRandomCode(40));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
console.log("options", e), this.globalData.options = e, t.getLogin(this, !0);
|
console.log("options", e), this.globalData.options = e, t.getLogin(this, !0);
|
||||||
try {
|
try {
|
||||||
var o = wx.getSystemInfoSync();
|
var o = wx.getSystemInfoSync();
|
||||||
|
@ -27,6 +27,7 @@ function n(a) {
|
|||||||
|
|
||||||
return wx.showLoading(), new Promise(function (n, c) {
|
return wx.showLoading(), new Promise(function (n, c) {
|
||||||
console.log("requestdevicecode", o.globalData.devicecode);
|
console.log("requestdevicecode", o.globalData.devicecode);
|
||||||
|
|
||||||
var i = Object.assign({}, {
|
var i = Object.assign({}, {
|
||||||
devicecode: o.globalData.devicecode
|
devicecode: o.globalData.devicecode
|
||||||
}, o.globalData.options, t);
|
}, o.globalData.options, t);
|
||||||
@ -36,7 +37,7 @@ function n(a) {
|
|||||||
header: {
|
header: {
|
||||||
"content-type": "application/json",
|
"content-type": "application/json",
|
||||||
Accept: "application/json, text/plain",
|
Accept: "application/json, text/plain",
|
||||||
Cookie: "_miucms_session=" + wx.getStorageSync("_miucms_session"),
|
Cookie: "XPHP_SESSION_ID=" + wx.getStorageSync("session"),
|
||||||
token: wx.getStorageSync("session") || ""
|
token: wx.getStorageSync("session") || ""
|
||||||
},
|
},
|
||||||
method: method,
|
method: method,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user