server: 修改鉴权请求头字段,去掉下划线

This commit is contained in:
2021-11-07 23:31:58 +08:00
parent 9760528ed0
commit ab65a58552
3 changed files with 9 additions and 37 deletions
+5 -2
View File
@@ -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);