Skip to content

Commit 74677b7

Browse files
authored
Merge pull request #947 from Tamcodes4/fix/auth-upload-photo
fix: protect profile photo upload route
2 parents 8e738cb + 3c5f660 commit 74677b7

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

backend/routes/users.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import path from "path";
44
import fs from "fs";
55
import { fileURLToPath } from "url";
66
import { fileTypeFromFile } from "file-type";
7+
import { requireAuth } from "../middlewares/requireAuth.js";
78

89
const __filename = fileURLToPath(import.meta.url);
910
const __dirname = path.dirname(__filename);
@@ -70,7 +71,7 @@ const safeUnlink = (filePath) => {
7071
};
7172

7273
// User profile photo upload endpoint
73-
router.post("/upload-photo", uploadProfilePhoto, async (req, res) => {
74+
router.post("/upload-photo", requireAuth, uploadProfilePhoto, async (req, res) => {
7475
if (!req.file) {
7576
return res.status(400).json({ error: "No file uploaded or invalid file type." });
7677
}

0 commit comments

Comments
 (0)