From f17c400839f34735933370ad054c99ce1c4a3262 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=A5=E5=AE=B6=E8=BE=89?= Date: Wed, 24 Jul 2024 22:49:15 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20#52=20=E4=BF=AE=E5=A4=8D=E5=85=A8?= =?UTF-8?q?=E5=B1=80=E9=89=B4=E6=9D=83=E5=BC=95=E5=8F=91=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.js | 2 +- routers/files.js | 4 ++++ routers/users.js | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 6bc417d..ddbe35d 100755 --- a/index.js +++ b/index.js @@ -17,7 +17,7 @@ const app = new Koa(); app.use(cors()); -app.use(authenticateToken); +// app.use(authenticateToken); app.use(koaBody()); diff --git a/routers/files.js b/routers/files.js index 575c0e1..c3d72a4 100644 --- a/routers/files.js +++ b/routers/files.js @@ -9,9 +9,11 @@ const { v4: uuidv4 } = require("uuid"); const JSZip = require("jszip"); const { filesize } = require("filesize"); +const authenticateToken = require("../middleware/authenticateToken"); const { detectFileType } = require("../utils/detectFileType"); const Files = require("../models/files"); const Users = require("../models/users"); + const { imageMimeTypes, tinifySupportedMimeTypes, @@ -32,6 +34,8 @@ const { tinify.key = process.env.TINIFY_KEY; const router = new Router(); +router.use(authenticateToken) + const uploadDirectory = path.join(__dirname, "..", "resource"); // 修改后的上传目录 const iconsDirectory = path.join(__dirname, "..", "public", "icons"); diff --git a/routers/users.js b/routers/users.js index 86657ff..a4a76d8 100644 --- a/routers/users.js +++ b/routers/users.js @@ -1,3 +1,4 @@ +const authenticateToken = require("../middleware/authenticateToken"); const Router = require("koa-router"); const redisClient = require("../redis"); const bcrypt = require("bcrypt"); @@ -15,6 +16,7 @@ const { validateBody, validateParams } = require("../types"); const { USER_STATUS, USER_ACTION_TYPES } = require("../constants/users"); const router = new Router(); +router.use(authenticateToken) router.post("/sessions", validateBody(USERS_LOGIN_POST), async (ctx) => { const { username, password } = ctx.request.body;