diff --git a/server/endpoints/system.js b/server/endpoints/system.js index 9924ec69468033525617988ffcd1cf675d56e1dc..d060e503f0b86efe5d999bdb05f61007dd959f0f 100644 --- a/server/endpoints/system.js +++ b/server/endpoints/system.js @@ -659,24 +659,18 @@ function systemEndpoints(app) { async function (request, response) { try { const { id } = request.params; - const pfpPath = await determinePfpFilepath(id); + if (response.locals?.user?.id !== Number(id)) + return response.sendStatus(204).end(); - if (!pfpPath) { - response.sendStatus(204).end(); - return; - } + const pfpPath = await determinePfpFilepath(id); + if (!pfpPath) return response.sendStatus(204).end(); const { found, buffer, size, mime } = fetchPfp(pfpPath); - if (!found) { - response.sendStatus(204).end(); - return; - } + if (!found) return response.sendStatus(204).end(); response.writeHead(200, { "Content-Type": mime || "image/png", - "Content-Disposition": `attachment; filename=${path.basename( - pfpPath - )}`, + "Content-Disposition": `attachment; filename=${path.basename(pfpPath)}`, "Content-Length": size, }); response.end(Buffer.from(buffer, "base64"));