server: 修改鉴权请求头字段,去掉下划线
This commit is contained in:
@@ -3,13 +3,13 @@
|
||||
"dataDir": "/home/master/desktop",
|
||||
"serve": true,
|
||||
"httpHost": "localhost",
|
||||
"httpPort": 9200,
|
||||
"httpPort": 8094,
|
||||
"debugMode": false,
|
||||
"baseUrl": "http://localhost:9200",
|
||||
"baseUrl": "http://localhost:8094",
|
||||
"appCode": {
|
||||
"mattuy-laptop": "iasdjfkwe3ds-qw3rjkwjfda8"
|
||||
"debug": "debug"
|
||||
},
|
||||
"appAuthHash": {
|
||||
"mattuy-laptop": "b9c901e0ee98486361b2e5461442af3f3863961f"
|
||||
"debug": ""
|
||||
}
|
||||
}
|
||||
@@ -61,34 +61,3 @@ async function start() {
|
||||
}
|
||||
|
||||
start();
|
||||
|
||||
// let sessionData = JSON.parse(
|
||||
// fs.readFileSync("/home/master/desktop/session.json"),
|
||||
// {
|
||||
// encoding: "utf-8",
|
||||
// }
|
||||
// );
|
||||
// const W = require("wechat4u");
|
||||
// const bot = new W(sessionData);
|
||||
// bot.on("uuid", (uuid) => {
|
||||
// qrCode.generate("https://login.weixin.qq.com/l/" + uuid, {
|
||||
// small: true,
|
||||
// });
|
||||
// });
|
||||
|
||||
// bot.on("login", async () => {
|
||||
// console.log("logged in");
|
||||
// fs.writeFileSync(
|
||||
// "/home/master/desktop/session.json",
|
||||
// JSON.stringify(bot.botData)
|
||||
// );
|
||||
// const { mediaId } = await bot.uploadMedia(
|
||||
// fs.createReadStream("/home/master/desktop/q.jpg"),
|
||||
// undefined,
|
||||
// "filehelper"
|
||||
// );
|
||||
// bot.sendPic(mediaId, "filehelper").then((rse) => {
|
||||
// console.log(rse);
|
||||
// });
|
||||
// });
|
||||
// bot.restart();
|
||||
|
||||
@@ -40,7 +40,10 @@ io.use((socket, next) => {
|
||||
if (!appCode || appCode !== auth.appCode) {
|
||||
return next(Error("认证失败"));
|
||||
}
|
||||
if (textSHA1(auth.passphrase) !== config.appAuthHash[appName]) {
|
||||
if (
|
||||
config.appAuthHash[appName] &&
|
||||
textSHA1(auth.passphrase) !== config.appAuthHash[appName]
|
||||
) {
|
||||
return next(Error("口令错误"));
|
||||
}
|
||||
if (activeSessions.has(socket.handshake.auth.sessionID)) {
|
||||
@@ -268,7 +271,7 @@ router.get("/session/:sessionID/media/:composedID/:filename", (ctx, next) => {
|
||||
|
||||
/** 上传文件 */
|
||||
router.post("/upload_file", async (ctx, next) => {
|
||||
if (!activeSessions.has(ctx.request.headers.session_id)) {
|
||||
if (!activeSessions.has(ctx.request.headers['sid'])) {
|
||||
ctx.throw(401);
|
||||
}
|
||||
const filename = dayjs().format("YYYYMMDD_") + String(Math.random()).slice(2);
|
||||
|
||||
Reference in New Issue
Block a user