Skip to content

Commit

Permalink
Merge pull request #53 from diskcloud/feature/52
Browse files Browse the repository at this point in the history
fix: #52 修复全局鉴权引发的问题
  • Loading branch information
CrazyMrYan authored Jul 24, 2024
2 parents 79a0939 + f17c400 commit 5e105c4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const app = new Koa();

app.use(cors());

app.use(authenticateToken);
// app.use(authenticateToken);

app.use(koaBody());

Expand Down
4 changes: 4 additions & 0 deletions routers/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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");

Expand Down
2 changes: 2 additions & 0 deletions routers/users.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const authenticateToken = require("../middleware/authenticateToken");
const Router = require("koa-router");
const redisClient = require("../redis");
const bcrypt = require("bcrypt");
Expand All @@ -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;
Expand Down

0 comments on commit 5e105c4

Please sign in to comment.